标签:
/* 贪心,很明显是越容易升级的越先升级 */ #include<iostream> #include<cstdio> #include<string> #include<cstring> #include<algorithm> using namespace std; const int maxn = 100050; int n,k,t,a[maxn],lv[maxn],ans; int read(){ char ch=getchar(); int x=0,f=1; while(!(ch>=‘0‘&&ch<=‘9‘)){if(ch==‘-‘)f=-1;ch=getchar();}; while(ch>=‘0‘&&ch<=‘9‘){x=x*10+(ch-‘0‘);ch=getchar();}; return x*f; } bool cmp(int a,int b){ return (a % 10) > (b % 10); } int main(){ freopen("science.in","r",stdin); freopen("science.out","w",stdout); n = read(); k = read(); for(int i = 1;i <= n;i++) a[i] = read(); sort(a+1,a+1+n,cmp); for(int i = 1;i <= n;i++){ lv[i] = a[i] / 10; t = 10 - (a[i] % 10); if(k >= t && lv[i] <= 9){ k -= t; lv[i]++; a[i] = 0; } } for(int i = 1;i <= n;i++){ if(lv[i] <= 9){ t = min(10-lv[i],k/10); lv[i] += t; k -= t*10; } ans += lv[i]; } cout<<ans; return 0; }
标签:
原文地址:http://www.cnblogs.com/hyfer/p/5982017.html