[AtCoder AGC27A]Candy Distribution Again】的更多相关文章

题目大意:把$x$个糖果分给$n$个人,必须分完,如果第$i$个人拿到$a_i$个糖果,就会开心,输出最多多少人开心 题解:从小到大排序,判断是否可以让他开心,注意最后判断是否要少一个人(没分完) 卡点:无 C++ Code: #include <cstdio> #include <algorithm> #define maxn 111 int n, x, ans; int a[maxn]; int main() { scanf("%d%d", &n,…
目录 题目链接 题解 代码 题目链接 AGC027 A - Candy Distribution Again 题解 贪心即可 代码 #include<cstdio> #include<cstring> #include<algorithm> #define gc getchar() #define pc putchar inline int read() { int x = 0,f = 1; char c = gc; while(c < '0' || c >…
Candy Distribution 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5291 Description WY has n kind of candy, number 1-N, The i-th kind of candy has ai. WY would like to give some of the candy to his teammate Ecry and lasten. To be fair, he hopes that…
Candy Distribution Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 544    Accepted Submission(s): 214   Problem DescriptionWY has n kind of candy, number 1-N, The i-th kind of candy has ai. WY w…
Kids like candies, so much that they start beating each other if the candies are not fairly distributed. So on your next party, you better start thinking before you buy the candies. If there are KK kids, we of course need K⋅XK⋅X candies for a fair di…
Problem Statement There are N piles of candies on the table. The piles are numbered 1 through N. At first, pile i contains ai candies. Snuke and Ciel are playing a game. They take alternating turns. Snuke goes first. In each turn, the current player…
神仙题..表示自己智商不够想不到... 好几次读成最后拿的赢了,导致一直没看懂题解... 题目链接: https://atcoder.jp/contests/agc002/tasks/agc002_e 题解: 首先所有数从大到小排序,如果把每个数上面画出高度等于它数值的柱状图,那么就可以得到一条从左上角走到右下角的Lattice Path, 两人从原点开始每一步操作就相当于向右或向上走一格,走到边界的输. 那么朴素的DP是\(O(\sum a_i)\)的,考虑优化: 找规律可得从一个不在边界上的…
可以证明: f(k) = k *(k - 1)/ 2 (1 ≤ k ≤ n)是n的完全剩余系当且仅当n = 2 ^ t. http://poj.org/problem?id=3372…
Description AGC027A 你有一些糖果,你要把这些糖果一个不剩分给一些熊孩子,但是这帮熊孩子只要特定数目的糖果,否则就会不开心,求最多的开心人数. Solution 如果\(\sum a_i = x\)的话,答案就是\(N\),否则答案一定小于\(N\).对于一个熊孩子们的真子集\(S\),如果\(\sum_{a_i\in S} a_i \le x\),那么一定可以满足这些孩子,然后把剩下的糖果任意分配到剩下的孩子手中即可.这样我们只需要找到最大的\(S\),排序后贪心即可.但是不…
目录 @description@ @solution@ @accepted code@ @details@ @description@ 给定 N 堆糖果,第 i 堆包含 ai 个糖果. 现在两人进行博弈.有两种操作选择: (1)吃掉包含最多糖果的糖果堆. (2)每堆吃掉一颗. 吃掉最后一颗糖的人判输,问谁必胜? 原题传送门. @solution@ 将 n 个数从大到小排好序,看成一个 n 列的直方图,第 i 列包含 a'i 个格子. 举个例子:对于 5 5 3 2 1 1,可以建立直方图如下:…