CodeForces 672D Robin Hood】的更多相关文章

D. Robin Hood time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output We all know the impressive story of Robin Hood. Robin Hood uses his archery skills and his wits to steal the money from rich, a…
思维. 当$k$趋向于正无穷时,答案会呈现出两种情况,不是$0$就是$1$.我们可以先判断掉答案为$1$和$0$的情况,剩下的情况都需要计算. 需要计算的就是,将最小的几个数总共加$k$次,最小值最大会是多少,以及将最大的几个数总共减$k$次,最大值最小可能是多少.两者相减就是答案. #pragma comment(linker, "/STACK:1024000000,1024000000") #include<cstdio> #include<cstring>…
D. Robin Hood time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output We all know the impressive story of Robin Hood. Robin Hood uses his archery skills and his wits to steal the money from rich, a…
题目链接: http://codeforces.com/problemset/problem/671/B 题目大意: N个人,每个人有Ci钱,现在有一个人劫富济贫,从最富的人之一拿走1元,再给最穷的人.总共K次,问最后贫富差距. 钱被拿走是立刻结算,所以可能拿走后这个人变最穷的人再还回去. 最富或最穷的人可能有多个,随机选择,并且不会影响最终答案. (1 ≤ n ≤ 500 000, 0 ≤ k ≤ 109) 题目思路: [模拟] 直接排序离散化数据,之后模拟就行. 细节挺多的要处理清楚. //…
题意:有n个人,每个人a[i]个物品,进行k次操作,每次都从最富有的人手里拿走一个物品给最穷的人 问k次操作以后,物品最多的人和物品最少的人相差几个物品 分析:如果次数足够多的话,最后的肯定在平均值上下,小的最多被补到sum/n,大最多减少到sum/n,或者sum/n+1 然后就二分最小值,看所有小的是否能在k次被填满 二分最大值,看所有大的是否都在k次被抹平 然后就是二分的写法,小和大的不一样,需要加等号,避免死循环 #include <stdio.h> #include <strin…
题目链接: D. Robin Hood time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output We all know the impressive story of Robin Hood. Robin Hood uses his archery skills and his wits to steal the money from r…
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output We all know the impressive story of Robin Hood. Robin Hood uses his archery skills and his wits to steal the money from rich, and return it to th…
B. Robin Hood 题目连接: http://www.codeforces.com/contest/671/problem/B Description We all know the impressive story of Robin Hood. Robin Hood uses his archery skills and his wits to steal the money from rich, and return it to the poor. There are n citiz…
D. Robin Hood   We all know the impressive story of Robin Hood. Robin Hood uses his archery skills and his wits to steal the money from rich, and return it to the poor. There are n citizens in Kekoland, each person has ci coins. Each day, Robin Hood…
[题目]B. Robin Hood [题意]给定n个数字的序列和k次操作,每次将序列中最大的数-1,然后将序列中最小的数+1,求最终序列极差.n<=5*10^5,0<=k<=10^9,1<=ai<=10^9. [算法]模拟 [题解]关键在于,增加和减少可以分开操作. 将数列排序,从小到大增加前面若干个数到同一个数直到k次,再从大到小减少后面若干个数到同一个数直到k次,就可以得到结果. 也可以不排序直接二分”同一个数”找到恰好k次的位置. #include<cstdio&…