当前位置: 首页 > news >正文

各大网站网址是多少网站以下内容未做缓存

各大网站网址是多少,网站以下内容未做缓存,百度品牌广告多少钱一个月,可以做mc图片的网站文章目录 题目来源T1#xff1a;5900: 【DP】小红书2023秋招提前批-连续子数组最大和5801: 【二分查找】小红书2023秋招提前批-精华帖子解法1——排序滑动窗口解法2——前缀和 二分查找 5000: 【模拟】小红书2023秋招提前批-小红的数组构造解法——数学 5300: 【哈希表】小红… 文章目录 题目来源T15900: 【DP】小红书2023秋招提前批-连续子数组最大和5801: 【二分查找】小红书2023秋招提前批-精华帖子解法1——排序滑动窗口解法2——前缀和 二分查找 5000: 【模拟】小红书2023秋招提前批-小红的数组构造解法——数学 5300: 【哈希表】小红书2023秋招-推荐系统 题目来源 红书2023秋招提前批算法真题解析 T15900: 【DP】小红书2023秋招提前批-连续子数组最大和 https://oj.algomooc.com/problem.php?id5900 做这题之前可以先做一下力扣中的53. 最大子数组和 作为前置知识。 每次询问就是一批输入数据。 定义 dp 数组 [n][2] 表示 以 a[i] 为结尾且选 a[i] 的子数组的最大和是多少第二维的 0 和 1 分别表示当前有没有将元素换成 x 的操作。 import java.util.*;class Main {public static void main(String[] args) {Scanner sc new Scanner(System.in);int t sc.nextInt();while (t-- ! 0) {int n sc.nextInt(), x sc.nextInt();int[] a new int[n];int[][] dp new int[n][2]; // 没变和变了for (int i 0; i n; i) a[i] sc.nextInt();dp[0][0] a[0];dp[0][1] x;int ans Math.max(dp[0][0], dp[0][1]);for (int i 1; i n; i) {dp[i][0] Math.max(dp[i - 1][0] a[i], a[i]);dp[i][1] Math.max(dp[i - 1][1] a[i], dp[i - 1][0] x);ans Math.max(ans, Math.max(dp[i][0], dp[i][1]));}System.out.println(ans);}} }5801: 【二分查找】小红书2023秋招提前批-精华帖子 https://oj.algomooc.com/problem.php?id5801 这道题目很像2271. 毯子覆盖的最多白色砖块数 解法1——排序滑动窗口 该解法的解析见【LeetCode周赛】2022上半年题目精选集——双指针 import java.util.*;class Main {public static void main(String[] args) {Scanner sc new Scanner(System.in);int n sc.nextInt(), m sc.nextInt(), k sc.nextInt();int[][] e new int[m][2];for (int i 0; i m; i) {e[i][0] sc.nextInt();e[i][1] sc.nextInt();}// 排序Arrays.sort(e, (x, y) - x[0] - y[0]);int ans 0, sum 0;// 开滑(枚举右端点尝试移动左端点)for (int l 0, r 0; r m; r) {sum e[r][1] - e[r][0];// 把超过的移出去while (e[r][1] - e[l][1] k) {sum - e[l][1] - e[l][0];l;}// 检查第一个区间是否占完了if (e[r][1] - k e[l][0]) {ans Math.max(ans, sum - (e[r][1] - k - e[l][0]));} else ans Math.max(ans, sum);}System.out.println(ans);} }解法2——前缀和 二分查找 前缀和是为了快速求出一个区间中的精华区一共有多少个精华帖子。 二分查找是为了快速找出以某一个精华区为起点时最后一个被覆盖到的精华区的索引。 import java.util.*;class Main {public static void main(String[] args) {Scanner sc new Scanner(System.in);int n sc.nextInt(), m sc.nextInt(), k sc.nextInt();int[][] e new int[m][2];int[] s new int[m 1];for (int i 0; i m; i) {e[i][0] sc.nextInt();e[i][1] sc.nextInt();s[i 1] s[i] e[i][1] - e[i][0];}int ans 0;for (int i 0; i m; i) { // 枚举每个瓷砖作为起始瓷砖// 使用二分查找最后一个被覆盖到的瓷砖int l i, r m - 1;while (l r) {int mid l r 1 1;if (e[i][0] k e[mid][0]) r mid - 1;else l mid;}ans Math.max(ans, s[l] - s[i] Math.min(e[i][0] k, e[l][1]) - e[l][0]);}System.out.println(ans);} }5000: 【模拟】小红书2023秋招提前批-小红的数组构造 解法——数学 冷静思考—— 最后的数组是这样的 k , 2 ∗ k , 3 ∗ k , . . . n ∗ k {k,2*k,3*k,...n*k} k,2∗k,3∗k,...n∗k 使用等差数列求和公式得答案为 k ∗ n ∗ ( n 1 ) / 2 k * n * (n 1) / 2 k∗n∗(n1)/2 import java.util.*;class Main {public static void main(String[] args) {Scanner sc new Scanner(System.in);int n sc.nextInt(), k sc.nextInt();System.out.println((long)k * n * (n 1) / 2);} }记得要转 long 否则答案会溢出 int。 5300: 【哈希表】小红书2023秋招-推荐系统 https://oj.algomooc.com/problem.php?id5300# 按照题目要求读取数据存入哈希表做计数统计。 将结果放入列表自定义筛选和排序即可。 import java.util.*;class Main {public static void main(String[] args) {Scanner sc new Scanner(System.in);MapString, Integer cnt new HashMap();while (sc.hasNext()) {String word sc.next();cnt.merge(word, 1, Integer::sum);}ListPair ls new ArrayList();for (Map.EntryString, Integer entry: cnt.entrySet()) {if (entry.getValue() 3) {ls.add(new Pair(entry.getKey(), entry.getValue()));}}Collections.sort(ls, (x, y) - {int c1 x.value, c2 y.value;return c1 ! c2? c2 - c1: x.key.compareTo(y.key);});for (Pair p: ls) {System.out.println(p.key);}} }class Pair {String key;Integer value;Pair(String key, Integer value) {this.key key;this.value value;} }
http://www.dnsts.com.cn/news/7317.html

相关文章:

  • 视频网站seo怎么做站内关键词排名优化软件
  • 汽车配件生产企业网站模板网站建设网页制
  • 中国建设银行官网站贺岁产品无法定位 wordpress 根目录.
  • 我的网站为什么打不开怎么回事啊沈阳鹊起网站建设公司
  • 高端个性化网站开发自己建网站怎么推广
  • 做公司网站的费用gui设计师
  • 茂名建设局网站微信会员卡系统怎么做
  • 南宁制作网站新浪博客怎么上传wordpress
  • php网站开发实训感想seo技术大师
  • 建立网站一般会遇到什么问题工程建设标准化期刊网站
  • 河北做网站公司那家好做设计用图片的网站
  • 视频类的网站制作批量翻译wordpress内容
  • 外贸公司建网站一般多少钱孝感网站开发培训机构
  • 做网站还是做淘宝高中信息技术网站设计规划
  • 北京网站制作公司飞沐河南郑州旅游景点
  • 郑州老牌做企业网站浏览器下载安装2022最新版
  • 建设网站公司名称大全网站系统目前运行稳定
  • 网站开发寻找潜在客户的途径鄂尔多斯做网站
  • 建设门户网站请示大连百度网站排名优化
  • 搭建网站复杂吗WordPress博客手机主题
  • 网站怎么做前台跟后台的接口画册设计说明
  • 企业网站建设的三个核心问题建e网室内设计网官网电脑app下载
  • wordpress 网站加载过慢6seo搜索引擎优化工作内容
  • 网站宣传内容公司简介介绍
  • 外贸网站有哪些平台国外的创意设计网站
  • 网站开发常用的语言企业网站如何做
  • 建站之星网站山西网站seo
  • 不需要备案如何做网站广元市利州区建设局网站
  • 网站建设成功案例Wordpress建站安装教程图解
  • 门户网站规划工商注册营业执照网址