# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
169688 |
2019-12-22T09:17:32 Z |
stefdasca |
Money (IZhO17_money) |
C++14 |
|
1370 ms |
62836 KB |
#include<bits/stdc++.h>
#define god dimasi5eks
#pragma GCC optimize("O3")
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define mod 1000000007
#define dancila 3.14159265359
#define eps 1e-9
using namespace std;
typedef long long ll;
int n, ans = 1, v[1000002], mx[1000002];
bool iz[1000002];
set<int> s;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> n;
for(int i = 1; i <= n; ++i)
{
cin >> v[i];
mx[i] = max(mx[i-1], v[i]);
}
iz[v[1]] = 1;
s.insert(v[1]);
int i = 2;
while(i <= n && v[i] >= v[i-1])
{
if(!iz[v[i]])
s.insert(v[i]);
++i;
}
for(; i <= n; )
{
++ans;
if(v[i] >= mx[i])
{
int j = i+1;
if(!iz[v[i]])
iz[v[i]] = 1, s.insert(v[i]);
while(j <= n && v[j] >= v[j-1])
{
if(!iz[v[j]])
iz[v[j]] = 1, s.insert(v[j]);
++j;
}
i = j;
}
else
{
set<int> ::iterator it = s.lower_bound(v[i]);
set<int> ::iterator it2 = it;
int val = *it;
if(it == s.begin() && v[i] < val)
{
int j = i+1;
if(!iz[v[i]])
iz[v[i]] = 1, s.insert(v[i]);
while(j <= n && v[j] >= v[j-1] && v[j] <= val)
{
if(!iz[v[j]])
iz[v[j]] = 1, s.insert(v[j]);
++j;
}
i = j;
}
else
{
if(val == v[i])
{
++it2;
if(it2 == s.end())
{
int j = i+1;
if(!iz[v[i]])
iz[v[i]] = 1, s.insert(v[i]);
while(j <= n && v[j] >= v[j-1])
{
if(!iz[v[j]])
iz[v[j]] = 1, s.insert(v[j]);
++j;
}
i = j;
}
else
{
int j = i+1;
int val2 = *it2;
if(!iz[v[i]])
iz[v[i]] = 1, s.insert(v[i]);
while(j <= n && v[j] >= v[j-1] && v[j] <= val2)
{
if(!iz[v[j]])
iz[v[j]] = 1, s.insert(v[j]);
++j;
}
i = j;
}
}
else
{
int j = i+1;
if(!iz[v[i]])
iz[v[i]] = 1, s.insert(v[i]);
while(j <= n && v[j] >= v[j-1] && v[j] <= val)
{
if(!iz[v[j]])
iz[v[j]] = 1, s.insert(v[j]);
++j;
}
i = j;
}
}
}
}
cout << ans;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
380 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
2 ms |
376 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
376 KB |
Output is correct |
15 |
Correct |
2 ms |
376 KB |
Output is correct |
16 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
380 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
2 ms |
376 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
376 KB |
Output is correct |
15 |
Correct |
2 ms |
376 KB |
Output is correct |
16 |
Correct |
2 ms |
376 KB |
Output is correct |
17 |
Correct |
2 ms |
376 KB |
Output is correct |
18 |
Correct |
2 ms |
376 KB |
Output is correct |
19 |
Correct |
2 ms |
376 KB |
Output is correct |
20 |
Correct |
2 ms |
376 KB |
Output is correct |
21 |
Correct |
2 ms |
504 KB |
Output is correct |
22 |
Correct |
2 ms |
376 KB |
Output is correct |
23 |
Correct |
2 ms |
376 KB |
Output is correct |
24 |
Correct |
2 ms |
376 KB |
Output is correct |
25 |
Correct |
2 ms |
376 KB |
Output is correct |
26 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
380 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
2 ms |
376 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
376 KB |
Output is correct |
15 |
Correct |
2 ms |
376 KB |
Output is correct |
16 |
Correct |
2 ms |
376 KB |
Output is correct |
17 |
Correct |
2 ms |
376 KB |
Output is correct |
18 |
Correct |
2 ms |
376 KB |
Output is correct |
19 |
Correct |
2 ms |
376 KB |
Output is correct |
20 |
Correct |
2 ms |
376 KB |
Output is correct |
21 |
Correct |
2 ms |
504 KB |
Output is correct |
22 |
Correct |
2 ms |
376 KB |
Output is correct |
23 |
Correct |
2 ms |
376 KB |
Output is correct |
24 |
Correct |
2 ms |
376 KB |
Output is correct |
25 |
Correct |
2 ms |
376 KB |
Output is correct |
26 |
Correct |
2 ms |
376 KB |
Output is correct |
27 |
Correct |
2 ms |
376 KB |
Output is correct |
28 |
Correct |
2 ms |
376 KB |
Output is correct |
29 |
Correct |
2 ms |
376 KB |
Output is correct |
30 |
Correct |
2 ms |
376 KB |
Output is correct |
31 |
Correct |
2 ms |
376 KB |
Output is correct |
32 |
Correct |
2 ms |
376 KB |
Output is correct |
33 |
Correct |
2 ms |
376 KB |
Output is correct |
34 |
Correct |
3 ms |
380 KB |
Output is correct |
35 |
Correct |
2 ms |
376 KB |
Output is correct |
36 |
Correct |
2 ms |
376 KB |
Output is correct |
37 |
Correct |
3 ms |
888 KB |
Output is correct |
38 |
Correct |
3 ms |
760 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
380 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
2 ms |
376 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
376 KB |
Output is correct |
15 |
Correct |
2 ms |
376 KB |
Output is correct |
16 |
Correct |
2 ms |
376 KB |
Output is correct |
17 |
Correct |
2 ms |
376 KB |
Output is correct |
18 |
Correct |
2 ms |
376 KB |
Output is correct |
19 |
Correct |
2 ms |
376 KB |
Output is correct |
20 |
Correct |
2 ms |
376 KB |
Output is correct |
21 |
Correct |
2 ms |
504 KB |
Output is correct |
22 |
Correct |
2 ms |
376 KB |
Output is correct |
23 |
Correct |
2 ms |
376 KB |
Output is correct |
24 |
Correct |
2 ms |
376 KB |
Output is correct |
25 |
Correct |
2 ms |
376 KB |
Output is correct |
26 |
Correct |
2 ms |
376 KB |
Output is correct |
27 |
Correct |
2 ms |
376 KB |
Output is correct |
28 |
Correct |
2 ms |
376 KB |
Output is correct |
29 |
Correct |
2 ms |
376 KB |
Output is correct |
30 |
Correct |
2 ms |
376 KB |
Output is correct |
31 |
Correct |
2 ms |
376 KB |
Output is correct |
32 |
Correct |
2 ms |
376 KB |
Output is correct |
33 |
Correct |
2 ms |
376 KB |
Output is correct |
34 |
Correct |
3 ms |
380 KB |
Output is correct |
35 |
Correct |
2 ms |
376 KB |
Output is correct |
36 |
Correct |
2 ms |
376 KB |
Output is correct |
37 |
Correct |
3 ms |
888 KB |
Output is correct |
38 |
Correct |
3 ms |
760 KB |
Output is correct |
39 |
Correct |
73 ms |
6952 KB |
Output is correct |
40 |
Correct |
116 ms |
9080 KB |
Output is correct |
41 |
Correct |
55 ms |
6008 KB |
Output is correct |
42 |
Correct |
54 ms |
5496 KB |
Output is correct |
43 |
Correct |
38 ms |
4012 KB |
Output is correct |
44 |
Correct |
143 ms |
10584 KB |
Output is correct |
45 |
Correct |
140 ms |
10700 KB |
Output is correct |
46 |
Correct |
141 ms |
10616 KB |
Output is correct |
47 |
Correct |
167 ms |
10564 KB |
Output is correct |
48 |
Correct |
133 ms |
10524 KB |
Output is correct |
49 |
Correct |
606 ms |
30068 KB |
Output is correct |
50 |
Correct |
587 ms |
29920 KB |
Output is correct |
51 |
Correct |
601 ms |
30164 KB |
Output is correct |
52 |
Correct |
585 ms |
30088 KB |
Output is correct |
53 |
Correct |
596 ms |
30196 KB |
Output is correct |
54 |
Correct |
577 ms |
30048 KB |
Output is correct |
55 |
Correct |
1296 ms |
58492 KB |
Output is correct |
56 |
Correct |
1330 ms |
58480 KB |
Output is correct |
57 |
Correct |
1308 ms |
58476 KB |
Output is correct |
58 |
Correct |
1370 ms |
58308 KB |
Output is correct |
59 |
Correct |
1361 ms |
58444 KB |
Output is correct |
60 |
Correct |
1344 ms |
58248 KB |
Output is correct |
61 |
Correct |
1308 ms |
58380 KB |
Output is correct |
62 |
Correct |
1338 ms |
62836 KB |
Output is correct |