CodeForces 589 I Lottery
来源:互联网 发布:淘宝网 北京 编辑:程序博客网 时间:2024/05/01 12:49
题意是给出一些数,问最少改变多少数字可以使它们出现频率相等。
那么只统计超过平均数的那些,多出来的,肯定是需要被改变的。
#include<stdio.h>#include<iostream>#include<math.h>#include<string.h>#include<iomanip>#include<stdlib.h>#include<ctype.h>#include<algorithm>#include<deque>#include<functional>#include<iterator>#include<vector>#include<list>#include<map>#include<queue>#include<set>#include<stack>#include<sstream>#define CPY(A,B)memcpy(A,B,sizeof(A))typedef long long LL;typedef unsigned long long uLL;const int MOD=1e9+7;const int INF=0x3f3f3f3f;const LL INFF=0x3f3f3f3f3f3f3f3fLL;const double EPS=1e-9;const double OO=1e20;const double PI=acos (-1.0);int dx[]= {0,1,0,-1};int dy[]= {1,0,-1,0};int gcd (const LL &a,const LL &b) {return b==0?a:gcd (b,a%b);}using namespace std;int col[110];int main() { int n,k; memset (col,0,sizeof col); scanf ("%d%d",&n,&k); for (int i=1; i<=n; ++i) { int t; scanf ("%d",&t); col[t]++; } int m=n/k,ans=0; for (int i=1; i<=k; ++i) { if (col[i]<m) { continue; } else {ans+= (col[i]-m);} } printf ("%d\n",ans); return 0;}
0 0
- CodeForces 589I Lottery
- CodeForces 589 I Lottery
- I. Lottery
- CodeForces 5891 Lottery
- Lottery
- codeforces 589I(水题)
- 【2015-2016 ACM-ICPC, NEERC, Southern Subregional Contest I】【水题】Lottery 均分气球最小修改数
- On Lottery
- Another lottery
- Welfare Lottery and Sports Lottery
- CodeForces Gym 100735I
- Codeforces 120I
- CodeForces 883I
- CodeForces 630I(规律题)
- codeforces 630I Parking Lot
- Codeforces 44I Toys (构造)
- Codeforces 630I Parking Lot
- codeforces #630 I. Parking Lot
- Javascript模块化编程(一):模块的写法
- CentOS7 mariaDB的安装
- 从今天开始搭建ACM判题系统---点滴记录:第一天---20160816
- bzoj3209(二进制数位dp)
- uva 1309 数独【DLX】
- CodeForces 589 I Lottery
- sysrq
- Set
- <html:reset>标签submit后无效
- UVA-1368
- Ubuntu设置
- 网游实时同步
- LUOGU 1196 并查集
- OC学习日记012(一)通知——观察者模式的另一种形式