CoderForce 140C-New Year Snowmen(贪心)】的更多相关文章

题目大意:有n个已知半径的雪球.堆一个雪人需要三个尺寸不同的雪球,问用这些雪球最多能堆多少个雪人? 题目分析:先统计一下每种尺寸的球的个数,从三种最多的种类中各取出一个堆成雪人,这样贪心能保证的到的数目最多. 代码如下: # include<iostream> # include<map> # include<vector> # include<cstdio> # include<queue> # include<algorithm>…
[题目链接] https://codeforces.com/problemset/problem/140/C [算法] 显然 , 我们每次应优先考虑数量多的雪球 将雪球个数加入堆中 , 每次取出数量前三大的雪球 , 贪心地将它们分到一个组中即可 时间复杂度 : O(N log N) [代码] #include<bits/stdc++.h> using namespace std; ; struct info { int v1 , v2 , v3; } ans[MAXN]; int n , to…
CF140C 贪心+优先队列 贪心策略:每次取出数量最多的三种球,合成一个答案,再把雪球数都-1再插回去,只要还剩下三种雪球就可以不断地合成 雪球数用优先队列维护 #include <bits/stdc++.h> using namespace std; const int N=1e5+5; int n,a[N],b[N],nm; struct ball{ int i,n; //i是离散数组中的编号,n为该种雪球的剩余数量 inline bool operator < (const ba…
题面 CodeForces 题解 因为要保证两两不同,所以不能单纯的开堆来维护,堆维护一个二元组,个数为第一关键字,编号为第二关键字,对于一个相同的颜色,统计一下这个颜色的个数再用堆来维护就好了. #include <cstdio> #include <cstring> #include <algorithm> #include <queue> using std::min; using std::max; using std::sort; using st…
C. New Year Snowmen time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output As meticulous Gerald sets the table and caring Alexander sends the postcards, Sergey makes snowmen. Each showman should cons…
题目大意:一个队伍,每个人只记得前面比他高的人的个数x.现在将队伍散开,问能否构造出一支满足条件的队伍,如果能,再给每个人一个满足题意的身高. 题目分析:一个一个排,x越少越先排,如果x比已经排好的人数大,那么无解.否则,将这个人放到已经排好的队伍中的第x+1个位置上去,并赋予一个合适的身高,使得前x个人都比他高. 代码如下: # include<iostream> # include<cstdio> # include<queue> # include<stri…
[链接] 我是链接,点我呀:) [题意] 题意 [题解] 每次都选择剩余个数最多的3个不同数字组成一组. 优先消耗剩余个数多的数字 这样能尽量让剩余的数字总数比较多,从而更加可能得到更多的3个组合 [代码] #include <bits/stdc++.h> using namespace std; const int N = 1e5; int n; map<int,int> dic; priority_queue<pair<int,int>,vector<p…
As meticulous Gerald sets the table and caring Alexander sends the postcards, Sergey makes snowmen. Each showman should consist of three snowballs: a big one, a medium one and a small one. Sergey's twins help him: they've already made n snowballs wit…
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…