-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path31022.cpp
48 lines (42 loc) · 924 Bytes
/
31022.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
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin>>n;
vector <int> want;
for(int i=0;i<n;i++)
{
int a;
cin>>a;
want.push_back(a);
}
sort(want.begin(),want.end());
reverse(&want.front(),&want.front()+n);
int result=0;
while(want.size()>0)
{
result++;
want[0]--;
if(want.size()>1)
want[1]--;
if(want.size()>2)
want[2]--;
if(want.size()>3)
want[3]--;
if(want.size()>3)
if(want[3]==0)
want.erase(want.begin()+3);
if(want.size()>2)
if(want[2]==0)
want.erase(want.begin()+2);
if(want.size()>1)
if(want[1]==0)
want.erase(want.begin()+1);
if(want[0]==0)
want.erase(want.begin()+0);
}
cout<<result<<endl;
return 0;
}