-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path16206.cpp
55 lines (48 loc) · 972 Bytes
/
16206.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
using namespace std;
int main(){
cin.tie(NULL);
ios_base::sync_with_stdio(false);
int N, M, a, cnt=0;
cin >> N >> M;
vector<int> v;
for(int i=0; i<N; i++){
cin >> a;
v.push_back(a);
}
sort(v.begin(), v.end());
for(int i=0; i<N; i++){
a = v[i];
if(v[i]%10==0){
while(a>10&&M>0){
a -= 10;
cnt++;
if(a>0){
M--;
}
}
if(a==10){
cnt++;
}
}
}
for(int i=0; i<N; i++){
a = v[i];
if(v[i]%10!=0){
while(a>10&&M>0){
a -= 10;
cnt++;
if(a>0){
M--;
}
}
if(a==10){
cnt++;
}
}
}
cout << cnt;
}