forked from Autoratch/Thailand-Olympiad-in-Informatics
-
Notifications
You must be signed in to change notification settings - Fork 0
/
toi08_fighter.cpp
64 lines (58 loc) · 1.05 KB
/
toi08_fighter.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
56
57
58
59
60
61
62
63
64
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define MOD 1e9 + 7
int main()
{
ios_base::sync_with_stdio(0); cin.tie(0);
int n;
cin >> n;
int o = 0,e = 0,po = n,pe = n;
n*=2;
for(int i = 0;i < n;i++)
{
int x;
cin >> x;
if(x%2==0)
{
if(e>=2)
{
e++;
po-=3;
}
else
{
po-=1;
if(e==0)
{
o = 0;
e = 1;
}
else e++;
}
}
else
{
if(o>=2)
{
o++;
pe-=3;
}
else
{
pe-=1;
if(o==0)
{
e = 0;
o = 1;
}
else o++;
}
}
if(pe<=0 or po<=0)
{
cout << x%2 << endl << x;
return 0;
}
}
}