CF/div2c/贪心】的更多相关文章

题目链接[http://codeforces.com/contest/749/problem/C] 题意:给出一个长度为n序列包含D和R,每一轮操作的先后顺序是1-n,规则是每一轮每个人有一次机会杀掉一个人,人死不能复生.问到最后剩下的人是D类人还是R类人. 思路:贪心+模拟.如果某个人有机会杀人,要杀掉还有机会杀人的不同类人,如果没有就杀掉位子靠前的已经用过杀人机会的不同类人. #include<bits/stdc++.h> using namespace std; ; char s[max…
Last year Bob earned by selling memory sticks. During each of n days of his work one of the two following events took place: A customer came to Bob and asked to sell him a 2x MB memory stick. If Bob had such a stick, he sold it and got 2x berllars. B…
D. Kostya the Sculptor time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output Kostya is a genial sculptor, he has an idea: to carve a marble sculpture in the shape of a sphere. Kostya has a frien…
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. /…
题目:http://codeforces.com/contest/949/problem/D 有二分答案的思路. 如果二分了一个答案,首先可知越靠中间的应该大约越容易满足,因为方便把别的房间的人聚集过来:所以如果二分了答案为 f ,可以认为合法的房间是除了前 f 个和后 f 个的剩下的房间. 但边缘房间自己能满足时也不用专门往中间跑,但一旦要跑,方向一定是向中间的:所以可以用指针判断: 可以认为 f 是合法房间的一个界限:指针走的时候累计一下已经有多少人,当又满足一个房间时,如果指针在界限 f…
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. 蜡烛可能在傍晚来临之前或者傍晚来临之后点亮,每秒只能点亮一支蜡烛,点亮…