CF 268E Playlist(贪心)】的更多相关文章

题目链接: 传送门 Playlist time limit per test:1 second     memory limit per test:256 megabytes Description Manao's friends often send him new songs. He never listens to them right away. Instead, he compiles them into a playlist. When he feels that his mind…
题目链接: http://codeforces.com/problemset/problem/268/E E. Playlist time limit per test 1 secondmemory limit per test 256 megabytes 问题描述 Manao's friends often send him new songs. He never listens to them right away. Instead, he compiles them into a play…
题目:http://codeforces.com/contest/949/problem/D 有二分答案的思路. 如果二分了一个答案,首先可知越靠中间的应该大约越容易满足,因为方便把别的房间的人聚集过来:所以如果二分了答案为 f ,可以认为合法的房间是除了前 f 个和后 f 个的剩下的房间. 但边缘房间自己能满足时也不用专门往中间跑,但一旦要跑,方向一定是向中间的:所以可以用指针判断: 可以认为 f 是合法房间的一个界限:指针走的时候累计一下已经有多少人,当又满足一个房间时,如果指针在界限 f…
Covered Path time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output The on-board computer on Polycarp's car measured that the car speed at the beginning of some section of the path equals v1 meter…
http://codeforces.com/contest/389/problem/E 这道题目刚开始想的特别麻烦...但是没想到竟然是贪心 我们只需要知道偶数的时候可以对称取的,然后奇数的时候没次取得就留下中间就可以了.最后对中间进行处理即可.…
http://codeforces.com/contest/462 A:Appleman and Easy Task 要求是否全部的字符都挨着偶数个'o' #include <cstdio> using namespace std; ][]; int n; ][]; ]={,,-,}; ]={,-,,}; int main(){ scanf("%d",&n); gets(maz[]); ;i<n;i++){ gets(maz[i]); } ;i<n;i+…
https://codeforces.com/contest/1257/problem/E 题意:有三个集合集合里面的数字可以随意变换位置,不同集合的数字,如从第一个A集合取一个数字到B集合那操作数+1,求最少操作次数使得一二三集合连起来是升序 我们先把每个集合排个序,然后拼起来,求一遍lis(最长升序序列:https://blog.csdn.net/Joined/article/details/78058362),然后n-len即为答案 网上那些什么dp什么的..嘻嘻太高深 #include<…
成就:赛后在cf使用错误的贪心通过一题 成就:在cf上赛后提交hack数据 成就:在cf上赛后hack自己 题目大意 有一长度$n \le 2\times 10^5$的序列,要求判断是否能够划分为一个严格递增和一个严格递减的子序列并给出划分方案. 题目分析 错误的贪心 截止现在(4.22),这一种错误贪心尚可以通过此题. 算法流程:考虑处理出一个LIS和一个LDS,并检查剩下的元素是否为LDS/LIS. 这个算法在随机构造下是基本没问题的(因此跑了47000+组随机数据才rand出一组反例).…
Codeforces Round #401 (Div. 2) 很happy,现场榜很happy,完全将昨晚的不悦忘了.终判我校一片惨白,小董同学怒怼D\E,离AK就差一个C了,于是我AC了C题还剩35分钟立刻开D题,不料英文苦涩难懂,懂了题意之后发现也是个水题,从后往前遍历一遍即可.然而代码速度和思维都不算很好,还有半分钟在徘徊要不要测一下样例,但又怕OJ卡了,直接交第一组就跪了,然后发现个小问题改改又直接交最后5秒然而以第一组WA结束本场CF. A  Shell Game 题意:有三个位置分别…
A. Detective Book 模拟题,有一些细节需要注意. #include <cstdio> #include <iostream> #include <cmath> using namespace std; const int N = 10010; int n, a[N], ans = 0; int main(){ scanf("%d", &n); for(int i = 1; i <= n; i++) scanf("…
1.CF #374 (Div. 2)   D. Maxim and Array 2.总结:按绝对值最小贪心下去即可 3.题意:对n个数进行+x或-x的k次操作,要使操作之后的n个数乘积最小. (1)优先队列 #include<bits/stdc++.h> #define F(i,a,b) for (int i=a;i<b;i++) #define FF(i,a,b) for (int i=a;i<=b;i++) #define mes(a,b) memset(a,b,sizeof(…
CF 628C 题目大意:给定一个长度为n(n < 10^5)的只含小写字母的字符串,以及一个数d,定义字符的dis--dis(ch1, ch2)为两个字符之差, 两个串的dis为各个位置上字符的dis之和,求和给定的字符串的dis为d的字符串,若含有多个则输出任意一个,不存在输出-1 解题思路:简单贪心,按顺序往后,对每一个字符,将其变为与它dis最大的字符(a或者z),d再减去相应的dis, 一直减到d为0,剩余的字母则不变直接输出.若一直到最后一位d仍然大于0,则说明不存在,输出-1. /…
C. Playlist time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You have a playlist consisting of nn songs. The ii-th song is characterized by two numbers titi and bibi — its length and beauty…
cf-Education 62-C 题目 C. Playlist time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You have a playlist consisting of nn songs. The ii-th song is characterized by two numbers titi and bibi -…
B. Clique Problem time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output The clique problem is one of the most well-known NP-complete problems. Under some simplification it can be formulated as f…
题目链接: [传送门][1] Pasha Maximizes time limit per test:1 second     memory limit per test:256 megabytes Description Pasha has a positive integer a without leading zeroes. Today he decided that the number is too small and he should make it larger. Unfortu…
题目链接: 传送门 Lawnmower time limit per test:2 second     memory limit per test:256 megabytes Description You have a garden consisting entirely of grass and weeds. Your garden is described by an n × m grid, with rows numbered 1 to n from top to bottom, an…
题目链接:http://codeforces.com/contest/508/problem/C 题目大意:给你三个数,m,t,r,代表晚上有m个幽灵,我有无限支蜡烛,每支蜡烛能够亮t秒,房间需要r支蜡烛才能被点亮. 接下来有m个数,w[0..m-1],每个幽灵会在w[i]秒来光顾,在w[i]+1秒结束光顾.当房间被点亮的时候,幽灵就不会来了,现在问你,最少需要多少支蜡烛,使得一晚上都没有幽灵来光顾.若不能达到,则输出-1. 蜡烛可能在傍晚来临之前或者傍晚来临之后点亮,每秒只能点亮一支蜡烛,点亮…
其实就是求总长度 - 一个最长“连续”自序列的长度 最长“连续”自序列即一个最长的lis,并且这个lis的值刚好是连续的,比如4,5,6... 遍历一遍,贪心就是了 遍历到第i个时,此时值为a[i],如果a[i]-1在前面已经出现过了,则len[a[i]] = len[a[i-1]]+1 否则len[a[i]] = 1 #include <cstdio> #include <algorithm> #include <cstring> #include <iostr…
New Year is coming, and Jaehyun decided to read many books during 2015, unlike this year. He has n books numbered by integers from 1 to n. The weight of the i-th (1 ≤ i ≤ n) book is wi. As Jaehyun's house is not large enough to have a bookshelf, he k…
Soldier and Badges time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output Colonel has n badges. He wants to give one badge to every of his n soldiers. Each badge has a coolness factor, which show…
Anya and Ghosts time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Anya loves to watch horror movies. In the best traditions of horror, she will be visited by m ghosts tonight. Anya has lots…
题目链接: http://codeforces.com/problemset/problem/332/C 题目意思: 有n个命令,要通过p个,某主席要在通过的p个中选择k个接受. 每个任务有两个值ai,bi, ai表示如果该主席接受该命令,她的头发变灰的数量,bi表示如果该主席不接受该命令时,议员不高兴值. 对于通过的p个命令,该主席要使议员的不高兴值和最小,在相同的情况下,要使自己的头发变灰的数量尽可能的少. 让你求出通过哪p个命令,使得该主席的头发变灰的数量最多,在相同的情况下,输出使议员不…
题目链接[http://codeforces.com/contest/749/problem/C] 题意:给出一个长度为n序列包含D和R,每一轮操作的先后顺序是1-n,规则是每一轮每个人有一次机会杀掉一个人,人死不能复生.问到最后剩下的人是D类人还是R类人. 思路:贪心+模拟.如果某个人有机会杀人,要杀掉还有机会杀人的不同类人,如果没有就杀掉位子靠前的已经用过杀人机会的不同类人. #include<bits/stdc++.h> using namespace std; ; char s[max…
题意:给你一堆汉诺塔的盘子,设内半径为a,设外半径为b,高度为h,如果bj ≤ bi 同时bj > ai 我们就认为i盘子能落在在j盘子上,问你最高能落多高 思路:一看题意我们就能想到贪心,首先我们对这些圆盘先按照b从大到小排序,如果b相同,那么就要按照a从大到小排序,其实落汉诺塔的过程就像在栈一样,先进后出,所以我们可以用栈来模拟落汉诺塔的过程,如果当前的不能落上我们就把最上面的盘子拿走,直到能落下一个盘子,每一次都计算一下当前的高度,并判断是否达到最高即可 代码: #include <bi…
题意:有一个小朋友,即喜欢下象棋,还喜欢编程,于是他打算上这两种课的兴趣班,这两种课有着不同的上课时间,他想让两堂课之间的休息时间最多,问最大时间是多少 思路:看到这道题的第一反应就是贪心,于是用结构体排个序然后再暴力枚举....果断超时了,其实只要找两个区间差最远的就可以了 代码: #include <bits/stdc++.h> #define inf 1e9 using namespace std; int main() { int l1,r1,l2,r2; l1=;r1=inf; l2…
Description: 非 * 号的地方可以放A或B,不能AA或BB,一共有a个A,b个B,问你最多放几个 Solution: 1.模拟一下,找连续空位长度,如果长度为奇数,则我可以有一个位置放任意一个,否则摆放消耗一定,最后放完了判断一下是不是还有剩下的,有剩下的就都放到任意位置 Code #include <iostream> #include <cstdio> #include <cstring> using namespace std; const int m…
Descripe: 贪心,贪在哪里呢…… 给你初始速度,结尾速度,行驶秒数,每秒速度可变化的范围,问你行驶秒数内最远可以行驶多少距离 Solution: 贪心,我是否加速,就是看剩下的时间能不能减到原始给定的结尾速度 #include <iostream> using namespace std; int main() { int v1,v2; int t,d; while(cin>>v1>>v2) { cin>>t>>d; int ret =…
是一道水题 虽然看起来像是DP,但其实是贪心 扫一遍就A了 QwQ #include <cstdio> #include <algorithm> #include <cstring> #include <set> #include <map> using namespace std; ],b[],f[]; ],bx[]; int main(){ scanf("%d",&n); scanf(); scanf(); ;i&…
Professor GukiZ is concerned about making his way to school, because massive piles of boxes are blocking his way. In total there are n piles of boxes, arranged in a line, from left to right, i-th pile (1 ≤ i ≤ n) containing ai boxes. Luckily, m stude…