【CF1251E】Voting(贪心)】的更多相关文章

题目传送门 贪心: 一个人 \(i\) 要投票,两种情况:花钱,或当前的人数达到了 \(m_i\). 而当前达到 \(m_i\) 的话所有 \(m_j \le m_i\) 也就达到要求了. 所以考虑将所有人按 \(m\) 从小到大排序.用 \(vetcor\) 当桶. 其次考虑如何贿赂最优.当前如果要达到 \(m_i\),优先考虑贿赂 \(m\) 更大的.因为贿赂比他小的可以达到的还是 \(m_i\),贿赂比他大的就可以达到 \(m_i+1\).同时,后面的要求比前面高,不用再考虑,会更优. 而…
题意:有n个人,需要搞到全部n个人的票,搞到第i个人的票有两种方式:之前已经搞到mi个人的票,或者直接花费pi 问最小的搞到所有票的总代价 n<=2e5,1<=p[i]<=1e9,0<=m[i]<n 思路:考虑从大到小白嫖上限K 对于mi<=K的必定白嫖,对于mi>K的维护一个待定集合,设集合大小为size 当事实上已确定选的人数,即n-size>=K时方案合法 确定K之后需要减小size,即每次从size中选出pi最小的购买 因为待定集合一定是以mi为第一…
题目链接: 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 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 wor…
Democracy in danger Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 3388   Accepted: 2508 Description In one of the countries of Caribbean basin all decisions were accepted by the simple majority of votes at the general meeting of citize…
1692: [Usaco2007 Dec]队列变换 Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 1383  Solved: 582[Submit][Status][Discuss] Description FJ打算带他的N(1 <= N <= 30,000)头奶牛去参加一年一度的“全美农场主大奖赛”.在这场比赛中,每个参赛者都必须让他的奶牛排成一列,然后领她们从裁判席前依次走过. 今年,竞赛委员会在接受队伍报名时,采用了一种新的登记规则:他们把所…
Wooden Sticks Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 15564    Accepted Submission(s): 6405 Problem Description There is a pile of n wooden sticks. The length and weight of each stick a…
FatMouse' Trade Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 56784    Accepted Submission(s): 19009 Problem Description FatMouse prepared M pounds of cat food, ready to trade with the cats g…
1691: [Usaco2007 Dec]挑剔的美食家 Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 786  Solved: 391[Submit][Status][Discuss] Description 与很多奶牛一样,Farmer John那群养尊处优的奶牛们对食物越来越挑剔,随便拿堆草就能打发她们午饭的日子自然是一去不返了.现在,Farmer John不得不去牧草专供商那里购买大量美味多汁的牧草,来满足他那N(1 <= N <= 100,…
http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n grid. In this game a ships are placed on the grid. Each of the ships consists of bconsecutive cells. No cell can be part of two ships, however, the shi…