#include <bits/stdc++.h>
#define ll long long
#define INF 998244353
using namespace std;
ll a[1011011];
set< ll > st;
int main()
{
ios_base::sync_with_stdio(0);
ll n;
cin>>n;
for(ll i = 1; i<= n; i ++ ){
cin>>a[i];
}
ll ans = 0, i;
st.insert(1000000000);
st.insert(0);
for( i = 1; i <= n; i ++ ){
ans++;
st.insert(a[i]);
auto x = st.upper_bound(a[i]);
while( i < n && a[i]<=a[i+1] && a[i+1]<=*x ){
st.insert(a[i+1]);
i++;
}
}
cout<<ans;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
464 KB |
Output is correct |
3 |
Correct |
2 ms |
464 KB |
Output is correct |
4 |
Correct |
2 ms |
544 KB |
Output is correct |
5 |
Correct |
2 ms |
600 KB |
Output is correct |
6 |
Correct |
2 ms |
608 KB |
Output is correct |
7 |
Correct |
2 ms |
608 KB |
Output is correct |
8 |
Correct |
2 ms |
608 KB |
Output is correct |
9 |
Correct |
2 ms |
608 KB |
Output is correct |
10 |
Correct |
2 ms |
696 KB |
Output is correct |
11 |
Correct |
2 ms |
696 KB |
Output is correct |
12 |
Correct |
2 ms |
708 KB |
Output is correct |
13 |
Correct |
2 ms |
708 KB |
Output is correct |
14 |
Correct |
2 ms |
708 KB |
Output is correct |
15 |
Correct |
2 ms |
708 KB |
Output is correct |
16 |
Correct |
2 ms |
708 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
464 KB |
Output is correct |
3 |
Correct |
2 ms |
464 KB |
Output is correct |
4 |
Correct |
2 ms |
544 KB |
Output is correct |
5 |
Correct |
2 ms |
600 KB |
Output is correct |
6 |
Correct |
2 ms |
608 KB |
Output is correct |
7 |
Correct |
2 ms |
608 KB |
Output is correct |
8 |
Correct |
2 ms |
608 KB |
Output is correct |
9 |
Correct |
2 ms |
608 KB |
Output is correct |
10 |
Correct |
2 ms |
696 KB |
Output is correct |
11 |
Correct |
2 ms |
696 KB |
Output is correct |
12 |
Correct |
2 ms |
708 KB |
Output is correct |
13 |
Correct |
2 ms |
708 KB |
Output is correct |
14 |
Correct |
2 ms |
708 KB |
Output is correct |
15 |
Correct |
2 ms |
708 KB |
Output is correct |
16 |
Correct |
2 ms |
708 KB |
Output is correct |
17 |
Correct |
2 ms |
708 KB |
Output is correct |
18 |
Correct |
2 ms |
708 KB |
Output is correct |
19 |
Correct |
2 ms |
708 KB |
Output is correct |
20 |
Correct |
2 ms |
708 KB |
Output is correct |
21 |
Correct |
2 ms |
708 KB |
Output is correct |
22 |
Correct |
2 ms |
708 KB |
Output is correct |
23 |
Correct |
2 ms |
708 KB |
Output is correct |
24 |
Correct |
2 ms |
708 KB |
Output is correct |
25 |
Correct |
2 ms |
708 KB |
Output is correct |
26 |
Correct |
2 ms |
708 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
464 KB |
Output is correct |
3 |
Correct |
2 ms |
464 KB |
Output is correct |
4 |
Correct |
2 ms |
544 KB |
Output is correct |
5 |
Correct |
2 ms |
600 KB |
Output is correct |
6 |
Correct |
2 ms |
608 KB |
Output is correct |
7 |
Correct |
2 ms |
608 KB |
Output is correct |
8 |
Correct |
2 ms |
608 KB |
Output is correct |
9 |
Correct |
2 ms |
608 KB |
Output is correct |
10 |
Correct |
2 ms |
696 KB |
Output is correct |
11 |
Correct |
2 ms |
696 KB |
Output is correct |
12 |
Correct |
2 ms |
708 KB |
Output is correct |
13 |
Correct |
2 ms |
708 KB |
Output is correct |
14 |
Correct |
2 ms |
708 KB |
Output is correct |
15 |
Correct |
2 ms |
708 KB |
Output is correct |
16 |
Correct |
2 ms |
708 KB |
Output is correct |
17 |
Correct |
2 ms |
708 KB |
Output is correct |
18 |
Correct |
2 ms |
708 KB |
Output is correct |
19 |
Correct |
2 ms |
708 KB |
Output is correct |
20 |
Correct |
2 ms |
708 KB |
Output is correct |
21 |
Correct |
2 ms |
708 KB |
Output is correct |
22 |
Correct |
2 ms |
708 KB |
Output is correct |
23 |
Correct |
2 ms |
708 KB |
Output is correct |
24 |
Correct |
2 ms |
708 KB |
Output is correct |
25 |
Correct |
2 ms |
708 KB |
Output is correct |
26 |
Correct |
2 ms |
708 KB |
Output is correct |
27 |
Correct |
2 ms |
708 KB |
Output is correct |
28 |
Correct |
2 ms |
708 KB |
Output is correct |
29 |
Correct |
2 ms |
748 KB |
Output is correct |
30 |
Correct |
2 ms |
748 KB |
Output is correct |
31 |
Correct |
2 ms |
748 KB |
Output is correct |
32 |
Correct |
2 ms |
748 KB |
Output is correct |
33 |
Correct |
2 ms |
748 KB |
Output is correct |
34 |
Correct |
2 ms |
748 KB |
Output is correct |
35 |
Correct |
2 ms |
748 KB |
Output is correct |
36 |
Correct |
2 ms |
748 KB |
Output is correct |
37 |
Correct |
2 ms |
748 KB |
Output is correct |
38 |
Correct |
2 ms |
748 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
464 KB |
Output is correct |
3 |
Correct |
2 ms |
464 KB |
Output is correct |
4 |
Correct |
2 ms |
544 KB |
Output is correct |
5 |
Correct |
2 ms |
600 KB |
Output is correct |
6 |
Correct |
2 ms |
608 KB |
Output is correct |
7 |
Correct |
2 ms |
608 KB |
Output is correct |
8 |
Correct |
2 ms |
608 KB |
Output is correct |
9 |
Correct |
2 ms |
608 KB |
Output is correct |
10 |
Correct |
2 ms |
696 KB |
Output is correct |
11 |
Correct |
2 ms |
696 KB |
Output is correct |
12 |
Correct |
2 ms |
708 KB |
Output is correct |
13 |
Correct |
2 ms |
708 KB |
Output is correct |
14 |
Correct |
2 ms |
708 KB |
Output is correct |
15 |
Correct |
2 ms |
708 KB |
Output is correct |
16 |
Correct |
2 ms |
708 KB |
Output is correct |
17 |
Correct |
2 ms |
708 KB |
Output is correct |
18 |
Correct |
2 ms |
708 KB |
Output is correct |
19 |
Correct |
2 ms |
708 KB |
Output is correct |
20 |
Correct |
2 ms |
708 KB |
Output is correct |
21 |
Correct |
2 ms |
708 KB |
Output is correct |
22 |
Correct |
2 ms |
708 KB |
Output is correct |
23 |
Correct |
2 ms |
708 KB |
Output is correct |
24 |
Correct |
2 ms |
708 KB |
Output is correct |
25 |
Correct |
2 ms |
708 KB |
Output is correct |
26 |
Correct |
2 ms |
708 KB |
Output is correct |
27 |
Correct |
2 ms |
708 KB |
Output is correct |
28 |
Correct |
2 ms |
708 KB |
Output is correct |
29 |
Correct |
2 ms |
748 KB |
Output is correct |
30 |
Correct |
2 ms |
748 KB |
Output is correct |
31 |
Correct |
2 ms |
748 KB |
Output is correct |
32 |
Correct |
2 ms |
748 KB |
Output is correct |
33 |
Correct |
2 ms |
748 KB |
Output is correct |
34 |
Correct |
2 ms |
748 KB |
Output is correct |
35 |
Correct |
2 ms |
748 KB |
Output is correct |
36 |
Correct |
2 ms |
748 KB |
Output is correct |
37 |
Correct |
2 ms |
748 KB |
Output is correct |
38 |
Correct |
2 ms |
748 KB |
Output is correct |
39 |
Correct |
72 ms |
4348 KB |
Output is correct |
40 |
Correct |
123 ms |
6804 KB |
Output is correct |
41 |
Correct |
59 ms |
6804 KB |
Output is correct |
42 |
Correct |
56 ms |
6804 KB |
Output is correct |
43 |
Correct |
40 ms |
6804 KB |
Output is correct |
44 |
Correct |
150 ms |
8472 KB |
Output is correct |
45 |
Correct |
151 ms |
8472 KB |
Output is correct |
46 |
Correct |
151 ms |
8472 KB |
Output is correct |
47 |
Correct |
142 ms |
8492 KB |
Output is correct |
48 |
Correct |
144 ms |
8500 KB |
Output is correct |
49 |
Correct |
713 ms |
27236 KB |
Output is correct |
50 |
Correct |
613 ms |
27236 KB |
Output is correct |
51 |
Correct |
573 ms |
27236 KB |
Output is correct |
52 |
Correct |
620 ms |
27236 KB |
Output is correct |
53 |
Correct |
596 ms |
27236 KB |
Output is correct |
54 |
Correct |
613 ms |
27236 KB |
Output is correct |
55 |
Correct |
1382 ms |
55376 KB |
Output is correct |
56 |
Execution timed out |
1573 ms |
62172 KB |
Time limit exceeded |
57 |
Halted |
0 ms |
0 KB |
- |