#include "bits/stdc++.h"
using namespace std;
#define pb push_back
#define mp make_pair
#define ll long long
#define int long long
#define itr iterator
typedef pair<ll,ll> pii;
const ll MAX=2e6;
const ll INF=1e12;
set<int> st;
set<int> ::itr it;
int N,res,arr[MAX];
signed main()
{
ios_base::sync_with_stdio(false);
cin>>N;
for(int A=1;A<=N;A++)
cin>>arr[A];
st.insert(0);
st.insert(MAX);
for(int A=1;A<=N;)
{
res++;
it=st.upper_bound(arr[A]);
while(A<=N)
{
st.insert(arr[A]);
if(arr[A+1]>=arr[A] and arr[A+1]<=*it)
A++;
else
break;
}
A++;
}
cout<<res;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
508 KB |
Output is correct |
3 |
Correct |
2 ms |
508 KB |
Output is correct |
4 |
Correct |
2 ms |
604 KB |
Output is correct |
5 |
Correct |
2 ms |
640 KB |
Output is correct |
6 |
Correct |
2 ms |
664 KB |
Output is correct |
7 |
Correct |
2 ms |
664 KB |
Output is correct |
8 |
Correct |
2 ms |
664 KB |
Output is correct |
9 |
Correct |
2 ms |
664 KB |
Output is correct |
10 |
Correct |
2 ms |
664 KB |
Output is correct |
11 |
Correct |
2 ms |
696 KB |
Output is correct |
12 |
Correct |
2 ms |
700 KB |
Output is correct |
13 |
Correct |
2 ms |
708 KB |
Output is correct |
14 |
Correct |
2 ms |
712 KB |
Output is correct |
15 |
Correct |
2 ms |
712 KB |
Output is correct |
16 |
Correct |
2 ms |
720 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
508 KB |
Output is correct |
3 |
Correct |
2 ms |
508 KB |
Output is correct |
4 |
Correct |
2 ms |
604 KB |
Output is correct |
5 |
Correct |
2 ms |
640 KB |
Output is correct |
6 |
Correct |
2 ms |
664 KB |
Output is correct |
7 |
Correct |
2 ms |
664 KB |
Output is correct |
8 |
Correct |
2 ms |
664 KB |
Output is correct |
9 |
Correct |
2 ms |
664 KB |
Output is correct |
10 |
Correct |
2 ms |
664 KB |
Output is correct |
11 |
Correct |
2 ms |
696 KB |
Output is correct |
12 |
Correct |
2 ms |
700 KB |
Output is correct |
13 |
Correct |
2 ms |
708 KB |
Output is correct |
14 |
Correct |
2 ms |
712 KB |
Output is correct |
15 |
Correct |
2 ms |
712 KB |
Output is correct |
16 |
Correct |
2 ms |
720 KB |
Output is correct |
17 |
Correct |
2 ms |
724 KB |
Output is correct |
18 |
Correct |
2 ms |
728 KB |
Output is correct |
19 |
Correct |
2 ms |
736 KB |
Output is correct |
20 |
Correct |
2 ms |
736 KB |
Output is correct |
21 |
Correct |
2 ms |
740 KB |
Output is correct |
22 |
Correct |
2 ms |
744 KB |
Output is correct |
23 |
Correct |
2 ms |
748 KB |
Output is correct |
24 |
Correct |
2 ms |
752 KB |
Output is correct |
25 |
Correct |
2 ms |
760 KB |
Output is correct |
26 |
Correct |
2 ms |
760 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
508 KB |
Output is correct |
3 |
Correct |
2 ms |
508 KB |
Output is correct |
4 |
Correct |
2 ms |
604 KB |
Output is correct |
5 |
Correct |
2 ms |
640 KB |
Output is correct |
6 |
Correct |
2 ms |
664 KB |
Output is correct |
7 |
Correct |
2 ms |
664 KB |
Output is correct |
8 |
Correct |
2 ms |
664 KB |
Output is correct |
9 |
Correct |
2 ms |
664 KB |
Output is correct |
10 |
Correct |
2 ms |
664 KB |
Output is correct |
11 |
Correct |
2 ms |
696 KB |
Output is correct |
12 |
Correct |
2 ms |
700 KB |
Output is correct |
13 |
Correct |
2 ms |
708 KB |
Output is correct |
14 |
Correct |
2 ms |
712 KB |
Output is correct |
15 |
Correct |
2 ms |
712 KB |
Output is correct |
16 |
Correct |
2 ms |
720 KB |
Output is correct |
17 |
Correct |
2 ms |
724 KB |
Output is correct |
18 |
Correct |
2 ms |
728 KB |
Output is correct |
19 |
Correct |
2 ms |
736 KB |
Output is correct |
20 |
Correct |
2 ms |
736 KB |
Output is correct |
21 |
Correct |
2 ms |
740 KB |
Output is correct |
22 |
Correct |
2 ms |
744 KB |
Output is correct |
23 |
Correct |
2 ms |
748 KB |
Output is correct |
24 |
Correct |
2 ms |
752 KB |
Output is correct |
25 |
Correct |
2 ms |
760 KB |
Output is correct |
26 |
Correct |
2 ms |
760 KB |
Output is correct |
27 |
Correct |
2 ms |
764 KB |
Output is correct |
28 |
Correct |
2 ms |
772 KB |
Output is correct |
29 |
Correct |
2 ms |
772 KB |
Output is correct |
30 |
Correct |
2 ms |
776 KB |
Output is correct |
31 |
Correct |
2 ms |
788 KB |
Output is correct |
32 |
Correct |
2 ms |
788 KB |
Output is correct |
33 |
Correct |
2 ms |
788 KB |
Output is correct |
34 |
Correct |
2 ms |
792 KB |
Output is correct |
35 |
Correct |
2 ms |
796 KB |
Output is correct |
36 |
Correct |
2 ms |
800 KB |
Output is correct |
37 |
Correct |
3 ms |
804 KB |
Output is correct |
38 |
Correct |
2 ms |
808 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
508 KB |
Output is correct |
3 |
Correct |
2 ms |
508 KB |
Output is correct |
4 |
Correct |
2 ms |
604 KB |
Output is correct |
5 |
Correct |
2 ms |
640 KB |
Output is correct |
6 |
Correct |
2 ms |
664 KB |
Output is correct |
7 |
Correct |
2 ms |
664 KB |
Output is correct |
8 |
Correct |
2 ms |
664 KB |
Output is correct |
9 |
Correct |
2 ms |
664 KB |
Output is correct |
10 |
Correct |
2 ms |
664 KB |
Output is correct |
11 |
Correct |
2 ms |
696 KB |
Output is correct |
12 |
Correct |
2 ms |
700 KB |
Output is correct |
13 |
Correct |
2 ms |
708 KB |
Output is correct |
14 |
Correct |
2 ms |
712 KB |
Output is correct |
15 |
Correct |
2 ms |
712 KB |
Output is correct |
16 |
Correct |
2 ms |
720 KB |
Output is correct |
17 |
Correct |
2 ms |
724 KB |
Output is correct |
18 |
Correct |
2 ms |
728 KB |
Output is correct |
19 |
Correct |
2 ms |
736 KB |
Output is correct |
20 |
Correct |
2 ms |
736 KB |
Output is correct |
21 |
Correct |
2 ms |
740 KB |
Output is correct |
22 |
Correct |
2 ms |
744 KB |
Output is correct |
23 |
Correct |
2 ms |
748 KB |
Output is correct |
24 |
Correct |
2 ms |
752 KB |
Output is correct |
25 |
Correct |
2 ms |
760 KB |
Output is correct |
26 |
Correct |
2 ms |
760 KB |
Output is correct |
27 |
Correct |
2 ms |
764 KB |
Output is correct |
28 |
Correct |
2 ms |
772 KB |
Output is correct |
29 |
Correct |
2 ms |
772 KB |
Output is correct |
30 |
Correct |
2 ms |
776 KB |
Output is correct |
31 |
Correct |
2 ms |
788 KB |
Output is correct |
32 |
Correct |
2 ms |
788 KB |
Output is correct |
33 |
Correct |
2 ms |
788 KB |
Output is correct |
34 |
Correct |
2 ms |
792 KB |
Output is correct |
35 |
Correct |
2 ms |
796 KB |
Output is correct |
36 |
Correct |
2 ms |
800 KB |
Output is correct |
37 |
Correct |
3 ms |
804 KB |
Output is correct |
38 |
Correct |
2 ms |
808 KB |
Output is correct |
39 |
Correct |
83 ms |
7728 KB |
Output is correct |
40 |
Correct |
132 ms |
15556 KB |
Output is correct |
41 |
Correct |
62 ms |
15556 KB |
Output is correct |
42 |
Correct |
58 ms |
16948 KB |
Output is correct |
43 |
Correct |
42 ms |
17740 KB |
Output is correct |
44 |
Correct |
174 ms |
30408 KB |
Output is correct |
45 |
Correct |
164 ms |
37252 KB |
Output is correct |
46 |
Correct |
249 ms |
43960 KB |
Output is correct |
47 |
Correct |
153 ms |
51064 KB |
Output is correct |
48 |
Correct |
161 ms |
57788 KB |
Output is correct |
49 |
Correct |
589 ms |
83156 KB |
Output is correct |
50 |
Correct |
592 ms |
89924 KB |
Output is correct |
51 |
Correct |
608 ms |
96736 KB |
Output is correct |
52 |
Correct |
586 ms |
103340 KB |
Output is correct |
53 |
Correct |
585 ms |
110364 KB |
Output is correct |
54 |
Correct |
616 ms |
116944 KB |
Output is correct |
55 |
Correct |
1276 ms |
152280 KB |
Output is correct |
56 |
Correct |
1253 ms |
158908 KB |
Output is correct |
57 |
Correct |
1280 ms |
165868 KB |
Output is correct |
58 |
Correct |
1299 ms |
172356 KB |
Output is correct |
59 |
Correct |
1320 ms |
178776 KB |
Output is correct |
60 |
Correct |
1350 ms |
185316 KB |
Output is correct |
61 |
Correct |
1358 ms |
192236 KB |
Output is correct |
62 |
Correct |
1252 ms |
198940 KB |
Output is correct |