码迷,mamicode.com
首页 > 其他好文 > 详细

繁华模拟赛day8 科技树

时间:2016-10-20 19:28:17      阅读:153      评论:0      收藏:0      [点我收藏+]

标签:

技术分享

技术分享

/*
贪心,很明显是越容易升级的越先升级
*/
#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;
} 

 

繁华模拟赛day8 科技树

标签:

原文地址:http://www.cnblogs.com/hyfer/p/5982017.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!