#include <bits/stdc++.h>
using namespace std;
#define sqr(x) ((x)*(x))
#define cube(x) ((x)*(x)*(x))
#define GCD(a, b) __gcd(a, b)
#define LCM(a, b) ((a)*(b)/GCD(a,b))
#define MP make_pair
#define n1 first
#define n2 second
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define SI set<int>
#define SL set<ll>
#define MS multiset
#define MSI multiset<int>
#define MSLL multiset<ll>
#define PB push_back
#define PF push_front
#define VI vector<int>
#define VPI vector<pair<int,int>>
#define VLL vector<ll>
#define SZ(x) ((int)x.size())
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double db;
const int INF = 1e9;
const int MOD = 1000000007;
const int N = 1001000;
const int M = 2511;
int a[N];
VI v[N];
void solve() {
int n;
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
set<int> s;
s.insert(-1);
s.insert(1e7);
int ans = 0;
int r = 1e7;
for (int i = 1; i <= n; i++) {
if (a[i] >= a[i - 1] && a[i] <= r) {
s.insert(a[i]);
} else {
// cout << " | ";
s.insert(a[i]);
r = *++s.find(a[i]);
ans++;
}
//cout << a[i] << ' ';
}
cout << ans + 1<< endl;
}
int main() {
ios_base::sync_with_stdio(false);
#ifdef dxz05
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#else
#endif
int T = 1;
//cin >> T;
while (T--) {
solve();
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
23 ms |
23928 KB |
Output is correct |
2 |
Correct |
23 ms |
23800 KB |
Output is correct |
3 |
Correct |
23 ms |
23800 KB |
Output is correct |
4 |
Correct |
23 ms |
23800 KB |
Output is correct |
5 |
Correct |
23 ms |
23800 KB |
Output is correct |
6 |
Correct |
23 ms |
23800 KB |
Output is correct |
7 |
Correct |
23 ms |
23928 KB |
Output is correct |
8 |
Correct |
23 ms |
23928 KB |
Output is correct |
9 |
Correct |
23 ms |
23928 KB |
Output is correct |
10 |
Correct |
23 ms |
23800 KB |
Output is correct |
11 |
Correct |
23 ms |
23928 KB |
Output is correct |
12 |
Correct |
22 ms |
23928 KB |
Output is correct |
13 |
Correct |
24 ms |
23800 KB |
Output is correct |
14 |
Correct |
23 ms |
23932 KB |
Output is correct |
15 |
Correct |
23 ms |
23928 KB |
Output is correct |
16 |
Correct |
23 ms |
23928 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
23 ms |
23928 KB |
Output is correct |
2 |
Correct |
23 ms |
23800 KB |
Output is correct |
3 |
Correct |
23 ms |
23800 KB |
Output is correct |
4 |
Correct |
23 ms |
23800 KB |
Output is correct |
5 |
Correct |
23 ms |
23800 KB |
Output is correct |
6 |
Correct |
23 ms |
23800 KB |
Output is correct |
7 |
Correct |
23 ms |
23928 KB |
Output is correct |
8 |
Correct |
23 ms |
23928 KB |
Output is correct |
9 |
Correct |
23 ms |
23928 KB |
Output is correct |
10 |
Correct |
23 ms |
23800 KB |
Output is correct |
11 |
Correct |
23 ms |
23928 KB |
Output is correct |
12 |
Correct |
22 ms |
23928 KB |
Output is correct |
13 |
Correct |
24 ms |
23800 KB |
Output is correct |
14 |
Correct |
23 ms |
23932 KB |
Output is correct |
15 |
Correct |
23 ms |
23928 KB |
Output is correct |
16 |
Correct |
23 ms |
23928 KB |
Output is correct |
17 |
Correct |
22 ms |
23800 KB |
Output is correct |
18 |
Correct |
24 ms |
23928 KB |
Output is correct |
19 |
Correct |
23 ms |
23928 KB |
Output is correct |
20 |
Correct |
23 ms |
23900 KB |
Output is correct |
21 |
Correct |
24 ms |
23928 KB |
Output is correct |
22 |
Correct |
23 ms |
23800 KB |
Output is correct |
23 |
Correct |
23 ms |
23932 KB |
Output is correct |
24 |
Correct |
23 ms |
23928 KB |
Output is correct |
25 |
Correct |
23 ms |
23800 KB |
Output is correct |
26 |
Correct |
23 ms |
23932 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
23 ms |
23928 KB |
Output is correct |
2 |
Correct |
23 ms |
23800 KB |
Output is correct |
3 |
Correct |
23 ms |
23800 KB |
Output is correct |
4 |
Correct |
23 ms |
23800 KB |
Output is correct |
5 |
Correct |
23 ms |
23800 KB |
Output is correct |
6 |
Correct |
23 ms |
23800 KB |
Output is correct |
7 |
Correct |
23 ms |
23928 KB |
Output is correct |
8 |
Correct |
23 ms |
23928 KB |
Output is correct |
9 |
Correct |
23 ms |
23928 KB |
Output is correct |
10 |
Correct |
23 ms |
23800 KB |
Output is correct |
11 |
Correct |
23 ms |
23928 KB |
Output is correct |
12 |
Correct |
22 ms |
23928 KB |
Output is correct |
13 |
Correct |
24 ms |
23800 KB |
Output is correct |
14 |
Correct |
23 ms |
23932 KB |
Output is correct |
15 |
Correct |
23 ms |
23928 KB |
Output is correct |
16 |
Correct |
23 ms |
23928 KB |
Output is correct |
17 |
Correct |
22 ms |
23800 KB |
Output is correct |
18 |
Correct |
24 ms |
23928 KB |
Output is correct |
19 |
Correct |
23 ms |
23928 KB |
Output is correct |
20 |
Correct |
23 ms |
23900 KB |
Output is correct |
21 |
Correct |
24 ms |
23928 KB |
Output is correct |
22 |
Correct |
23 ms |
23800 KB |
Output is correct |
23 |
Correct |
23 ms |
23932 KB |
Output is correct |
24 |
Correct |
23 ms |
23928 KB |
Output is correct |
25 |
Correct |
23 ms |
23800 KB |
Output is correct |
26 |
Correct |
23 ms |
23932 KB |
Output is correct |
27 |
Correct |
22 ms |
23928 KB |
Output is correct |
28 |
Correct |
23 ms |
23860 KB |
Output is correct |
29 |
Correct |
22 ms |
23928 KB |
Output is correct |
30 |
Correct |
22 ms |
23928 KB |
Output is correct |
31 |
Correct |
22 ms |
23804 KB |
Output is correct |
32 |
Correct |
22 ms |
23800 KB |
Output is correct |
33 |
Correct |
23 ms |
23928 KB |
Output is correct |
34 |
Correct |
23 ms |
23800 KB |
Output is correct |
35 |
Correct |
22 ms |
23800 KB |
Output is correct |
36 |
Correct |
23 ms |
23800 KB |
Output is correct |
37 |
Correct |
23 ms |
23800 KB |
Output is correct |
38 |
Correct |
22 ms |
23928 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
23 ms |
23928 KB |
Output is correct |
2 |
Correct |
23 ms |
23800 KB |
Output is correct |
3 |
Correct |
23 ms |
23800 KB |
Output is correct |
4 |
Correct |
23 ms |
23800 KB |
Output is correct |
5 |
Correct |
23 ms |
23800 KB |
Output is correct |
6 |
Correct |
23 ms |
23800 KB |
Output is correct |
7 |
Correct |
23 ms |
23928 KB |
Output is correct |
8 |
Correct |
23 ms |
23928 KB |
Output is correct |
9 |
Correct |
23 ms |
23928 KB |
Output is correct |
10 |
Correct |
23 ms |
23800 KB |
Output is correct |
11 |
Correct |
23 ms |
23928 KB |
Output is correct |
12 |
Correct |
22 ms |
23928 KB |
Output is correct |
13 |
Correct |
24 ms |
23800 KB |
Output is correct |
14 |
Correct |
23 ms |
23932 KB |
Output is correct |
15 |
Correct |
23 ms |
23928 KB |
Output is correct |
16 |
Correct |
23 ms |
23928 KB |
Output is correct |
17 |
Correct |
22 ms |
23800 KB |
Output is correct |
18 |
Correct |
24 ms |
23928 KB |
Output is correct |
19 |
Correct |
23 ms |
23928 KB |
Output is correct |
20 |
Correct |
23 ms |
23900 KB |
Output is correct |
21 |
Correct |
24 ms |
23928 KB |
Output is correct |
22 |
Correct |
23 ms |
23800 KB |
Output is correct |
23 |
Correct |
23 ms |
23932 KB |
Output is correct |
24 |
Correct |
23 ms |
23928 KB |
Output is correct |
25 |
Correct |
23 ms |
23800 KB |
Output is correct |
26 |
Correct |
23 ms |
23932 KB |
Output is correct |
27 |
Correct |
22 ms |
23928 KB |
Output is correct |
28 |
Correct |
23 ms |
23860 KB |
Output is correct |
29 |
Correct |
22 ms |
23928 KB |
Output is correct |
30 |
Correct |
22 ms |
23928 KB |
Output is correct |
31 |
Correct |
22 ms |
23804 KB |
Output is correct |
32 |
Correct |
22 ms |
23800 KB |
Output is correct |
33 |
Correct |
23 ms |
23928 KB |
Output is correct |
34 |
Correct |
23 ms |
23800 KB |
Output is correct |
35 |
Correct |
22 ms |
23800 KB |
Output is correct |
36 |
Correct |
23 ms |
23800 KB |
Output is correct |
37 |
Correct |
23 ms |
23800 KB |
Output is correct |
38 |
Correct |
22 ms |
23928 KB |
Output is correct |
39 |
Correct |
99 ms |
27052 KB |
Output is correct |
40 |
Correct |
151 ms |
28152 KB |
Output is correct |
41 |
Correct |
83 ms |
26488 KB |
Output is correct |
42 |
Correct |
80 ms |
26360 KB |
Output is correct |
43 |
Correct |
63 ms |
25976 KB |
Output is correct |
44 |
Correct |
181 ms |
28932 KB |
Output is correct |
45 |
Correct |
180 ms |
28976 KB |
Output is correct |
46 |
Correct |
180 ms |
28892 KB |
Output is correct |
47 |
Correct |
167 ms |
28924 KB |
Output is correct |
48 |
Correct |
170 ms |
28920 KB |
Output is correct |
49 |
Correct |
629 ms |
47508 KB |
Output is correct |
50 |
Correct |
573 ms |
47424 KB |
Output is correct |
51 |
Correct |
578 ms |
47352 KB |
Output is correct |
52 |
Correct |
572 ms |
47352 KB |
Output is correct |
53 |
Correct |
562 ms |
47608 KB |
Output is correct |
54 |
Correct |
568 ms |
47480 KB |
Output is correct |
55 |
Correct |
1476 ms |
76180 KB |
Output is correct |
56 |
Correct |
1491 ms |
75848 KB |
Output is correct |
57 |
Correct |
1291 ms |
76024 KB |
Output is correct |
58 |
Correct |
1302 ms |
75872 KB |
Output is correct |
59 |
Correct |
1277 ms |
76104 KB |
Output is correct |
60 |
Correct |
1307 ms |
75900 KB |
Output is correct |
61 |
Correct |
1311 ms |
76024 KB |
Output is correct |
62 |
Correct |
1304 ms |
76048 KB |
Output is correct |