# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
91194 |
2018-12-26T13:51:03 Z |
davitmarg |
Money (IZhO17_money) |
C++17 |
|
1500 ms |
25544 KB |
/*
DEATH-MATCH
Davit-Marg
*/
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <iterator>
#include <ctype.h>
#include <stdlib.h>
#include <fstream>
#define mod 1000000007ll
#define LL long long
#define LD long double
#define MP make_pair
#define PB push_back
using namespace std;
int n,ans,a[1000006],l,it;
stack<int> st;
int t[4 * 1000006];
void update(int v,int l,int r,int pos)
{
if (l == r)
{
t[v] = l;
return;
}
int m = (l + r) / 2;
if (pos <= m)
update(v * 2, l, m, pos);
else
update(v * 2 + 1, m + 1, r, pos);
t[v] = min(t[v * 2], t[v * 2 + 1]);
}
int query(int v, int l, int r, int i,int j)
{
if (l == i && r==j)
return t[v];
int m = (l + r) / 2;
if (j <= m)
return query(v * 2, l, m, i, j);
else if (i >= m + 1)
return query(v * 2 + 1, m + 1, r, i, j);
else
return min(query(v * 2, l, m, i, m), query(v * 2 + 1, m + 1, r, m + 1, j));
}
int main()
{
cin >> n;
ans = 1;
for (int i = 1; i <= n; i++)
scanf("%d", a+i);
for (int i = 0; i <= 4 * 1000000 + 2; i++)
t[i] = mod;
update(1, 0, 1000000, 0);
it = mod;
for (int i = 1; i <= n; i++)
{
if ((a[i] < a[i - 1]) || (it != mod && it < a[i]) )
{
l = a[i];
ans++;
while (!st.empty())
{
update(1, 0, 1000000, st.top());
st.pop();
}
it = query(1,0,1000000,l+1, 1000000);
}
st.push(a[i]);
}
cout << ans << endl;
return 0;
}
/*
6
1 3 5 2 4 6
*/
Compilation message
money.cpp: In function 'int main()':
money.cpp:64:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", a+i);
~~~~~^~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
15992 KB |
Output is correct |
2 |
Correct |
15 ms |
15996 KB |
Output is correct |
3 |
Correct |
15 ms |
16184 KB |
Output is correct |
4 |
Correct |
15 ms |
16184 KB |
Output is correct |
5 |
Correct |
14 ms |
16184 KB |
Output is correct |
6 |
Correct |
14 ms |
16184 KB |
Output is correct |
7 |
Correct |
14 ms |
16184 KB |
Output is correct |
8 |
Correct |
14 ms |
16204 KB |
Output is correct |
9 |
Correct |
14 ms |
16208 KB |
Output is correct |
10 |
Correct |
14 ms |
16208 KB |
Output is correct |
11 |
Correct |
14 ms |
16224 KB |
Output is correct |
12 |
Correct |
14 ms |
16228 KB |
Output is correct |
13 |
Correct |
15 ms |
16228 KB |
Output is correct |
14 |
Correct |
15 ms |
16228 KB |
Output is correct |
15 |
Correct |
15 ms |
16248 KB |
Output is correct |
16 |
Correct |
14 ms |
16260 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
15992 KB |
Output is correct |
2 |
Correct |
15 ms |
15996 KB |
Output is correct |
3 |
Correct |
15 ms |
16184 KB |
Output is correct |
4 |
Correct |
15 ms |
16184 KB |
Output is correct |
5 |
Correct |
14 ms |
16184 KB |
Output is correct |
6 |
Correct |
14 ms |
16184 KB |
Output is correct |
7 |
Correct |
14 ms |
16184 KB |
Output is correct |
8 |
Correct |
14 ms |
16204 KB |
Output is correct |
9 |
Correct |
14 ms |
16208 KB |
Output is correct |
10 |
Correct |
14 ms |
16208 KB |
Output is correct |
11 |
Correct |
14 ms |
16224 KB |
Output is correct |
12 |
Correct |
14 ms |
16228 KB |
Output is correct |
13 |
Correct |
15 ms |
16228 KB |
Output is correct |
14 |
Correct |
15 ms |
16228 KB |
Output is correct |
15 |
Correct |
15 ms |
16248 KB |
Output is correct |
16 |
Correct |
14 ms |
16260 KB |
Output is correct |
17 |
Correct |
15 ms |
16260 KB |
Output is correct |
18 |
Correct |
14 ms |
16260 KB |
Output is correct |
19 |
Correct |
14 ms |
16260 KB |
Output is correct |
20 |
Correct |
13 ms |
16264 KB |
Output is correct |
21 |
Correct |
15 ms |
16268 KB |
Output is correct |
22 |
Correct |
14 ms |
16272 KB |
Output is correct |
23 |
Correct |
14 ms |
16276 KB |
Output is correct |
24 |
Correct |
14 ms |
16280 KB |
Output is correct |
25 |
Correct |
15 ms |
16284 KB |
Output is correct |
26 |
Correct |
14 ms |
16288 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
15992 KB |
Output is correct |
2 |
Correct |
15 ms |
15996 KB |
Output is correct |
3 |
Correct |
15 ms |
16184 KB |
Output is correct |
4 |
Correct |
15 ms |
16184 KB |
Output is correct |
5 |
Correct |
14 ms |
16184 KB |
Output is correct |
6 |
Correct |
14 ms |
16184 KB |
Output is correct |
7 |
Correct |
14 ms |
16184 KB |
Output is correct |
8 |
Correct |
14 ms |
16204 KB |
Output is correct |
9 |
Correct |
14 ms |
16208 KB |
Output is correct |
10 |
Correct |
14 ms |
16208 KB |
Output is correct |
11 |
Correct |
14 ms |
16224 KB |
Output is correct |
12 |
Correct |
14 ms |
16228 KB |
Output is correct |
13 |
Correct |
15 ms |
16228 KB |
Output is correct |
14 |
Correct |
15 ms |
16228 KB |
Output is correct |
15 |
Correct |
15 ms |
16248 KB |
Output is correct |
16 |
Correct |
14 ms |
16260 KB |
Output is correct |
17 |
Correct |
15 ms |
16260 KB |
Output is correct |
18 |
Correct |
14 ms |
16260 KB |
Output is correct |
19 |
Correct |
14 ms |
16260 KB |
Output is correct |
20 |
Correct |
13 ms |
16264 KB |
Output is correct |
21 |
Correct |
15 ms |
16268 KB |
Output is correct |
22 |
Correct |
14 ms |
16272 KB |
Output is correct |
23 |
Correct |
14 ms |
16276 KB |
Output is correct |
24 |
Correct |
14 ms |
16280 KB |
Output is correct |
25 |
Correct |
15 ms |
16284 KB |
Output is correct |
26 |
Correct |
14 ms |
16288 KB |
Output is correct |
27 |
Correct |
14 ms |
16292 KB |
Output is correct |
28 |
Correct |
14 ms |
16296 KB |
Output is correct |
29 |
Correct |
14 ms |
16300 KB |
Output is correct |
30 |
Correct |
14 ms |
16304 KB |
Output is correct |
31 |
Correct |
15 ms |
16308 KB |
Output is correct |
32 |
Correct |
15 ms |
16312 KB |
Output is correct |
33 |
Correct |
15 ms |
16316 KB |
Output is correct |
34 |
Correct |
14 ms |
16332 KB |
Output is correct |
35 |
Correct |
14 ms |
16336 KB |
Output is correct |
36 |
Correct |
14 ms |
16344 KB |
Output is correct |
37 |
Correct |
14 ms |
16344 KB |
Output is correct |
38 |
Correct |
14 ms |
16348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
15992 KB |
Output is correct |
2 |
Correct |
15 ms |
15996 KB |
Output is correct |
3 |
Correct |
15 ms |
16184 KB |
Output is correct |
4 |
Correct |
15 ms |
16184 KB |
Output is correct |
5 |
Correct |
14 ms |
16184 KB |
Output is correct |
6 |
Correct |
14 ms |
16184 KB |
Output is correct |
7 |
Correct |
14 ms |
16184 KB |
Output is correct |
8 |
Correct |
14 ms |
16204 KB |
Output is correct |
9 |
Correct |
14 ms |
16208 KB |
Output is correct |
10 |
Correct |
14 ms |
16208 KB |
Output is correct |
11 |
Correct |
14 ms |
16224 KB |
Output is correct |
12 |
Correct |
14 ms |
16228 KB |
Output is correct |
13 |
Correct |
15 ms |
16228 KB |
Output is correct |
14 |
Correct |
15 ms |
16228 KB |
Output is correct |
15 |
Correct |
15 ms |
16248 KB |
Output is correct |
16 |
Correct |
14 ms |
16260 KB |
Output is correct |
17 |
Correct |
15 ms |
16260 KB |
Output is correct |
18 |
Correct |
14 ms |
16260 KB |
Output is correct |
19 |
Correct |
14 ms |
16260 KB |
Output is correct |
20 |
Correct |
13 ms |
16264 KB |
Output is correct |
21 |
Correct |
15 ms |
16268 KB |
Output is correct |
22 |
Correct |
14 ms |
16272 KB |
Output is correct |
23 |
Correct |
14 ms |
16276 KB |
Output is correct |
24 |
Correct |
14 ms |
16280 KB |
Output is correct |
25 |
Correct |
15 ms |
16284 KB |
Output is correct |
26 |
Correct |
14 ms |
16288 KB |
Output is correct |
27 |
Correct |
14 ms |
16292 KB |
Output is correct |
28 |
Correct |
14 ms |
16296 KB |
Output is correct |
29 |
Correct |
14 ms |
16300 KB |
Output is correct |
30 |
Correct |
14 ms |
16304 KB |
Output is correct |
31 |
Correct |
15 ms |
16308 KB |
Output is correct |
32 |
Correct |
15 ms |
16312 KB |
Output is correct |
33 |
Correct |
15 ms |
16316 KB |
Output is correct |
34 |
Correct |
14 ms |
16332 KB |
Output is correct |
35 |
Correct |
14 ms |
16336 KB |
Output is correct |
36 |
Correct |
14 ms |
16344 KB |
Output is correct |
37 |
Correct |
14 ms |
16344 KB |
Output is correct |
38 |
Correct |
14 ms |
16348 KB |
Output is correct |
39 |
Correct |
136 ms |
20080 KB |
Output is correct |
40 |
Correct |
235 ms |
21364 KB |
Output is correct |
41 |
Correct |
111 ms |
21364 KB |
Output is correct |
42 |
Correct |
111 ms |
21364 KB |
Output is correct |
43 |
Correct |
85 ms |
21364 KB |
Output is correct |
44 |
Correct |
288 ms |
22116 KB |
Output is correct |
45 |
Correct |
275 ms |
22172 KB |
Output is correct |
46 |
Correct |
326 ms |
22172 KB |
Output is correct |
47 |
Correct |
236 ms |
25372 KB |
Output is correct |
48 |
Correct |
251 ms |
25416 KB |
Output is correct |
49 |
Correct |
479 ms |
25508 KB |
Output is correct |
50 |
Correct |
436 ms |
25544 KB |
Output is correct |
51 |
Execution timed out |
1581 ms |
25544 KB |
Time limit exceeded |
52 |
Halted |
0 ms |
0 KB |
- |