随笔分类 -  排序

摘要:https://www.luogu.com.cn/problem/P1250 贪心,排序,差分约束黄色题 思路一: 区间选点问题 贪心,要种树种得少,就要使一棵树给多个区间使用,这样,尽量在重叠区间种树即可,而重叠位置一定是区间尾部。处理问题时,先按所有区间的结束位置从小到大排序,若结束位置相同,则 阅读全文 »
posted @ 2022-08-09 14:05 -イレイナ 阅读(66) 评论(0) 推荐(0) 编辑
摘要:https://www.luogu.com.cn/problem/P1167模拟,贪心,排序黄色题 思路: 1.计算出时间差 2.最后特别简单的贪心 读入: scanf("%d-%d-%d-%d:%d",&start[1],&start[2],&start[3],&start[4],&start[5 阅读全文 »
posted @ 2022-08-09 10:29 -イレイナ 阅读(81) 评论(0) 推荐(0) 编辑
摘要:https://www.luogu.com.cn/problem/P2370动态规划背包,排序,二分黄色题 思路一:01背包+排序 #include<cstdio> #include<algorithm> using namespace std; int n,p,s; int dp[1005];// 阅读全文 »
posted @ 2022-08-09 09:50 -イレイナ 阅读(26) 评论(0) 推荐(0) 编辑
摘要:https://www.luogu.com.cn/problem/P1716 涉及知识点:模拟,排序橙色题 思路: 我们先对所有的数来一下从大到小排序。定义两个变量,分别在头尾,输出所在位置上的数后互相靠近,直到越过彼此为止。 代码: include <iostream> #include <alg 阅读全文 »
posted @ 2022-07-07 07:48 -イレイナ 阅读(36) 评论(0) 推荐(0) 编辑
摘要:P1628 合并序列[普及-]https://www.luogu.com.cn/problem/P1628涉及知识点:字符串,排序,二叉堆 橙色题 思路: 主要用到的函数为find函数,find函数用来对原始数据中某个字符串进行定位,以确定其位置,返回位置。 判断是否是以字符串T为前缀的单词只需要find返回的数为0即可(因为是 阅读全文 »
posted @ 2022-07-07 07:38 -イレイナ 阅读(31) 评论(0) 推荐(0) 编辑
摘要:https://www.luogu.com.cn/problem/P1012涉及知识点:字符串,排序橙色题 代码: #include<iostream> #include<string> #include<algorithm>//提供sort using namespace std; string 阅读全文 »
posted @ 2022-07-06 13:25 -イレイナ 阅读(47) 评论(0) 推荐(0) 编辑
摘要:https://www.luogu.com.cn/problem/P1862涉及知识点:枚举暴力,模拟,排序橙色题 思路: 设东西向主管道的 yy 坐标是 mm ,则输油管道总长 S=|y1-m|+|y2-m|+...+|yn-m|, 题中的x坐标根本无用,因为管道必须从左到右连在一起,x是行一.将 阅读全文 »
posted @ 2022-07-05 21:52 -イレイナ 阅读(58) 评论(0) 推荐(0) 编辑
摘要:https://www.luogu.com.cn/problem/P1808涉及知识点:字符串,排序 橙色题 思路: 一.读入n和n个字符串 二.边读入字符串边将这个字符串内部从小到大排序 三.再将这n个字符串从小到大进行排序 四.因为这n个字符串从小到大排序,全部组成这个字符串的字母的数量相等的字 阅读全文 »
posted @ 2022-07-05 18:49 -イレイナ 阅读(34) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示