Codeforces 1251E Voting】的更多相关文章

E2. Voting (Hard Version) 题意: 有n个人, 你想让他们都给你投票. 你可以选择花费pi收买第i个人, 或者如果有mi个人已经给你投票了, 那么第i个人会自动给你投票. 不妨把题目等价为, 给n个人排一个先后投票的顺序, 假设在这个顺序中, 第k个投票的人, 它的mi不超过k-1, 那么这个人就不需要花钱收买, 否则就需要花钱收买. 那么我们依次考虑第1,2,3,....n个投票的位置让哪个人来投票. 可以发现, 只要我们让"不需要花钱收买的人省下的钱"最大化…
C. Voting time limit per test: 1 second memory limit per test: 256 megabytes input: standard input output: standard output There are n employees in Alternative Cake Manufacturing (ACM). They are now voting on some very important question and the lead…
C. Voting time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output There are n employees in Alternative Cake Manufacturing (ACM). They are now voting on some very important question and the leading…
题目链接: http://codeforces.com/contest/1251/problem/E2 题意: 主角需要获得n个人的投票 有两种方式让某个人投票 1,已经投票的人数大于m 2,花p枚硬币收买 数据范围: $1\leq n \leq 200 000$ 分析: 对$m$进行排序 保留前缀的$m$数组,$pre[x]$为$m$小于等于$x$的人数 对x逆序处理,当枚举到$x$的时候,假设$m$小于等于$x-1$的那些人已经投票,也就是有$pre[x-1]$人已经投票 如果$pre[x-…
有点意思的题 Voting CodeForces - 749C 题意:有n个人投票,每次按照第1个人~第n个人的顺序发言,如果到某个人发言时他已经被禁止发言就跳过,每个人发言时可以禁止另一个人发言或什么也不做.最后只剩下一个人时,那个人的意见就是最终决定的意见.这些人分为D和R两派,也就是每个人有D和R两种意见中的一种,每一派的人都希望自己派的意见成为最终意见.假设每个人都作出最优选择,请根据每个人的派别判断最终决定的意见. 方法:第i个人发言的时候,就按照第i~第n,第1~第i-1的顺序找出第…
http://codeforces.com/problemset/problem/749/C 题意:有n个人投票,分为 D 和 R 两派,从1~n的顺序投票,轮到某人投票的时候,他可以将对方的一个人KO,被KO的人不能投票了,这样循环,直到某一派的人全部被KO,问哪方赢. 思路:模拟..代码好懂.. #include <cstdio> #include <algorithm> #include <iostream> #include <cstring> #i…
题目链接: A. Voting for Photos time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output After celebrating the midcourse the students of one of the faculties of the Berland State University decided to co…
题意:有n个人,每个人要么是属于D派要么就是R派的.从编号1开始按顺序,每个人都有一次机会可以剔除其他任何一个人(被剔除的人就不在序列中也就失去了剔除其他人的机会了):当轮完一遍后就再次从头从仅存的人中从编号最小开始重复执行上述操作,直至仅存在一派,问最后获胜的是哪一派? 并且,题目假设每个人的选择是最优的,即每个人的操作都是会尽可能的让自己所属的派获胜的. 题解: 一开始看到说每个人的操作都会是最优的还以为是个博弈(=_=),,,仔细琢磨了下样例发现并不用,只要贪心模拟就行了.贪心的策略并不难…
大意: n个人, 两个党派, 轮流投票, 两种操作(1)ban掉一个人 (2)投票, 每轮一个未被ban的人可以进行一次操作(1)或操作(2), 求最终哪个党派得票最多. 显然先ban人会更优, 所以维护两个set模拟. 不过好像可以有O(n)的做法? #include <iostream> #include <sstream> #include <algorithm> #include <cstdio> #include <math.h> #i…
题目链接 :http://codeforces.com/contest/158/problem/D D. Ice Sculptures time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output The Berland University is preparing to celebrate the 256-th anniversary…