-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
51 lines (43 loc) · 976 Bytes
/
main.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
#include<bits/stdc++.h>
using namespace std;
int n,x;
int verify(vector<int> grades){
int sum=0;
for(int i=0;i<grades.size();i++){
if(grades[i]>grades.size()-1)
return 0;
sum+=grades[i];
}
if(sum %2 == 1 )
return 0;
return 1;
}
string answer(vector<int> grades){
if(verify(grades)){
while(grades.size() != 0 ){
sort(grades.begin(),grades.end(), greater<int>());
int a=grades[0];
grades.erase(grades.begin());
for(int i=0;i<a;i++){
if(grades[i]-1<0)
return "NU";
else
grades[i]-=1;
}
}
return "DA";
}
return "NU";
}
int main(){
vector<int> grades;
//int n = sizeof(grades) / sizeof(grades[0]);
cin>>n;
for(int i=0;i<n;i++)
{
cin>>x;
grades.push_back(x);
}
//n = sizeof(grades) / sizeof(grades[0]);
cout<<answer(grades);
}