【Henu ACM Round#19 C】 Developing Skills

【链接】 我是链接,点我呀:)
【题意】

在这里输入题意

【题解】

优先把不是10的倍数的变成10的倍数。 (优先%10比较大的数字增加

如果k还有剩余。
剩下的数字都是10的倍数了。
那么先加哪一个都可以了。

【代码】

#include <bits/stdc++.h>
using namespace std;

const int N = 1e5;

int a[N+10],n,k;
int b[N+10];
int point = 0;

int main()
{
    ios::sync_with_stdio(0),cin.tie(0);
    #ifdef LOCAL_DEFINE
        freopen("rush_in.txt","r",stdin);
    #endif
    cin >> n >> k;
    for (int i = 1;i <= n;i++) {
        cin >> a[i];
        point+=a[i]/10;
    }
    for (int i = 1;i <= n;i++){
        if ((a[i]%10)!=0){
            b[i] = 10 - (a[i]%10);
        }
        a[i]+=b[i];
        a[i] = 100-a[i];
    }
    sort(b+1,b+1+n);
    for (int i = 1;i <= n;i++)
        if (b[i]>0){
            if (k>=b[i]){
                k-=b[i];
                b[i] = 0;
                point++;
            }else {
                return cout<<point<<endl,0;
            }
        }
    for (int i = 1;i <= n;i++){
        int kk = a[i]/10;
        int k1 = k/10;
        point+=min(kk,k1);
        a[i]-=min(kk,k1)*10;
        k-=min(kk,k1)*10;
    }
    cout<<point<<endl;
    return 0;
}
posted @ 2018-02-01 11:39  AWCXV  阅读(112)  评论(0编辑  收藏  举报