贪心--cf、education62-C】的更多相关文章

题目链接: http://codeforces.com/problemset/problem/332/C 题目意思: 有n个命令,要通过p个,某主席要在通过的p个中选择k个接受. 每个任务有两个值ai,bi, ai表示如果该主席接受该命令,她的头发变灰的数量,bi表示如果该主席不接受该命令时,议员不高兴值. 对于通过的p个命令,该主席要使议员的不高兴值和最小,在相同的情况下,要使自己的头发变灰的数量尽可能的少. 让你求出通过哪p个命令,使得该主席的头发变灰的数量最多,在相同的情况下,输出使议员不…
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 -…
Removing Columns time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You are given an n × m rectangular table consisting of lower case English letters. In one operation you can completely remo…
链接 1.括号序列贪心/CF&51nod原题 [分析]: 贪心,每次到i的时候,假如你要在i里面要卖掉股票,获益是a[i], 肯定要在前面要么:1)把已经卖了的变成不买不卖,需要-a[j], 2)把已经不买不卖的变成买,需要-a[j] [原题链接]:CF&E CF&D 51nod高卖低买 3.构造/封闭运算/费马小定理下模意义/重新定义+和 * [题意]: 输入:素数p 要求构造规则a[p*p],使其满足:(m+n)^p=m^p+n^p a的含义: a[i][j] = (i-1)…
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…