标签:style blog http color io os ar for sp
# include<cstdio> # include<cstring> # include<algorithm> using namespace std; const int maxn=10000000+10; int n,k,t; unsigned long long tot; int num[maxn]; int main(){ freopen("fishing.in","r",stdin); freopen("fishing.out","w",stdout); int x,max=-0x7fffffff; scanf("%d%d%d",&n,&k,&t); for(int i=1;i<=n;i++){ scanf("%d",&x); num[x]++; if(x>max)max=x; } //for(int i=1;i<=4;i++)printf("%d ",num[i]); for(int i=1;i<=t;i++){ if(max>=k){ tot+=k; num[max]--; num[max-k]++; } else if(max<k) { tot+=max; num[max]--; num[0]++; } for(int j=max;j>=0;j--) if(num[j]){max=j;break;} if(max==0)break; } printf("%I64u",tot); return 0; }
标签:style blog http color io os ar for sp
原文地址:http://www.cnblogs.com/zoniony/p/4004724.html