#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.upper_bound(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 |
23800 KB |
Output is correct |
2 |
Correct |
23 ms |
23896 KB |
Output is correct |
3 |
Correct |
23 ms |
23928 KB |
Output is correct |
4 |
Correct |
23 ms |
23864 KB |
Output is correct |
5 |
Correct |
23 ms |
23800 KB |
Output is correct |
6 |
Correct |
26 ms |
23916 KB |
Output is correct |
7 |
Correct |
22 ms |
23800 KB |
Output is correct |
8 |
Correct |
27 ms |
23800 KB |
Output is correct |
9 |
Correct |
23 ms |
23900 KB |
Output is correct |
10 |
Correct |
23 ms |
23800 KB |
Output is correct |
11 |
Correct |
23 ms |
23800 KB |
Output is correct |
12 |
Correct |
24 ms |
23928 KB |
Output is correct |
13 |
Correct |
23 ms |
23928 KB |
Output is correct |
14 |
Correct |
24 ms |
23928 KB |
Output is correct |
15 |
Correct |
23 ms |
23928 KB |
Output is correct |
16 |
Correct |
23 ms |
23804 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
23 ms |
23800 KB |
Output is correct |
2 |
Correct |
23 ms |
23896 KB |
Output is correct |
3 |
Correct |
23 ms |
23928 KB |
Output is correct |
4 |
Correct |
23 ms |
23864 KB |
Output is correct |
5 |
Correct |
23 ms |
23800 KB |
Output is correct |
6 |
Correct |
26 ms |
23916 KB |
Output is correct |
7 |
Correct |
22 ms |
23800 KB |
Output is correct |
8 |
Correct |
27 ms |
23800 KB |
Output is correct |
9 |
Correct |
23 ms |
23900 KB |
Output is correct |
10 |
Correct |
23 ms |
23800 KB |
Output is correct |
11 |
Correct |
23 ms |
23800 KB |
Output is correct |
12 |
Correct |
24 ms |
23928 KB |
Output is correct |
13 |
Correct |
23 ms |
23928 KB |
Output is correct |
14 |
Correct |
24 ms |
23928 KB |
Output is correct |
15 |
Correct |
23 ms |
23928 KB |
Output is correct |
16 |
Correct |
23 ms |
23804 KB |
Output is correct |
17 |
Correct |
23 ms |
23804 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 |
23928 KB |
Output is correct |
21 |
Correct |
23 ms |
23932 KB |
Output is correct |
22 |
Correct |
23 ms |
23928 KB |
Output is correct |
23 |
Correct |
23 ms |
23928 KB |
Output is correct |
24 |
Correct |
23 ms |
23932 KB |
Output is correct |
25 |
Correct |
23 ms |
23932 KB |
Output is correct |
26 |
Correct |
23 ms |
23928 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
23 ms |
23800 KB |
Output is correct |
2 |
Correct |
23 ms |
23896 KB |
Output is correct |
3 |
Correct |
23 ms |
23928 KB |
Output is correct |
4 |
Correct |
23 ms |
23864 KB |
Output is correct |
5 |
Correct |
23 ms |
23800 KB |
Output is correct |
6 |
Correct |
26 ms |
23916 KB |
Output is correct |
7 |
Correct |
22 ms |
23800 KB |
Output is correct |
8 |
Correct |
27 ms |
23800 KB |
Output is correct |
9 |
Correct |
23 ms |
23900 KB |
Output is correct |
10 |
Correct |
23 ms |
23800 KB |
Output is correct |
11 |
Correct |
23 ms |
23800 KB |
Output is correct |
12 |
Correct |
24 ms |
23928 KB |
Output is correct |
13 |
Correct |
23 ms |
23928 KB |
Output is correct |
14 |
Correct |
24 ms |
23928 KB |
Output is correct |
15 |
Correct |
23 ms |
23928 KB |
Output is correct |
16 |
Correct |
23 ms |
23804 KB |
Output is correct |
17 |
Correct |
23 ms |
23804 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 |
23928 KB |
Output is correct |
21 |
Correct |
23 ms |
23932 KB |
Output is correct |
22 |
Correct |
23 ms |
23928 KB |
Output is correct |
23 |
Correct |
23 ms |
23928 KB |
Output is correct |
24 |
Correct |
23 ms |
23932 KB |
Output is correct |
25 |
Correct |
23 ms |
23932 KB |
Output is correct |
26 |
Correct |
23 ms |
23928 KB |
Output is correct |
27 |
Correct |
29 ms |
23800 KB |
Output is correct |
28 |
Correct |
23 ms |
23920 KB |
Output is correct |
29 |
Correct |
23 ms |
23928 KB |
Output is correct |
30 |
Correct |
22 ms |
23800 KB |
Output is correct |
31 |
Correct |
23 ms |
23928 KB |
Output is correct |
32 |
Correct |
23 ms |
23928 KB |
Output is correct |
33 |
Correct |
23 ms |
23928 KB |
Output is correct |
34 |
Correct |
23 ms |
23928 KB |
Output is correct |
35 |
Correct |
23 ms |
23800 KB |
Output is correct |
36 |
Correct |
22 ms |
23800 KB |
Output is correct |
37 |
Correct |
24 ms |
23800 KB |
Output is correct |
38 |
Correct |
23 ms |
23928 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
23 ms |
23800 KB |
Output is correct |
2 |
Correct |
23 ms |
23896 KB |
Output is correct |
3 |
Correct |
23 ms |
23928 KB |
Output is correct |
4 |
Correct |
23 ms |
23864 KB |
Output is correct |
5 |
Correct |
23 ms |
23800 KB |
Output is correct |
6 |
Correct |
26 ms |
23916 KB |
Output is correct |
7 |
Correct |
22 ms |
23800 KB |
Output is correct |
8 |
Correct |
27 ms |
23800 KB |
Output is correct |
9 |
Correct |
23 ms |
23900 KB |
Output is correct |
10 |
Correct |
23 ms |
23800 KB |
Output is correct |
11 |
Correct |
23 ms |
23800 KB |
Output is correct |
12 |
Correct |
24 ms |
23928 KB |
Output is correct |
13 |
Correct |
23 ms |
23928 KB |
Output is correct |
14 |
Correct |
24 ms |
23928 KB |
Output is correct |
15 |
Correct |
23 ms |
23928 KB |
Output is correct |
16 |
Correct |
23 ms |
23804 KB |
Output is correct |
17 |
Correct |
23 ms |
23804 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 |
23928 KB |
Output is correct |
21 |
Correct |
23 ms |
23932 KB |
Output is correct |
22 |
Correct |
23 ms |
23928 KB |
Output is correct |
23 |
Correct |
23 ms |
23928 KB |
Output is correct |
24 |
Correct |
23 ms |
23932 KB |
Output is correct |
25 |
Correct |
23 ms |
23932 KB |
Output is correct |
26 |
Correct |
23 ms |
23928 KB |
Output is correct |
27 |
Correct |
29 ms |
23800 KB |
Output is correct |
28 |
Correct |
23 ms |
23920 KB |
Output is correct |
29 |
Correct |
23 ms |
23928 KB |
Output is correct |
30 |
Correct |
22 ms |
23800 KB |
Output is correct |
31 |
Correct |
23 ms |
23928 KB |
Output is correct |
32 |
Correct |
23 ms |
23928 KB |
Output is correct |
33 |
Correct |
23 ms |
23928 KB |
Output is correct |
34 |
Correct |
23 ms |
23928 KB |
Output is correct |
35 |
Correct |
23 ms |
23800 KB |
Output is correct |
36 |
Correct |
22 ms |
23800 KB |
Output is correct |
37 |
Correct |
24 ms |
23800 KB |
Output is correct |
38 |
Correct |
23 ms |
23928 KB |
Output is correct |
39 |
Correct |
97 ms |
28940 KB |
Output is correct |
40 |
Correct |
148 ms |
30704 KB |
Output is correct |
41 |
Correct |
88 ms |
27868 KB |
Output is correct |
42 |
Correct |
78 ms |
27480 KB |
Output is correct |
43 |
Correct |
66 ms |
26488 KB |
Output is correct |
44 |
Correct |
178 ms |
31260 KB |
Output is correct |
45 |
Correct |
176 ms |
31224 KB |
Output is correct |
46 |
Correct |
177 ms |
31288 KB |
Output is correct |
47 |
Correct |
162 ms |
31224 KB |
Output is correct |
48 |
Correct |
167 ms |
31224 KB |
Output is correct |
49 |
Correct |
709 ms |
49828 KB |
Output is correct |
50 |
Correct |
594 ms |
49884 KB |
Output is correct |
51 |
Correct |
610 ms |
49768 KB |
Output is correct |
52 |
Correct |
609 ms |
49916 KB |
Output is correct |
53 |
Correct |
606 ms |
50032 KB |
Output is correct |
54 |
Correct |
614 ms |
49664 KB |
Output is correct |
55 |
Correct |
1340 ms |
78252 KB |
Output is correct |
56 |
Correct |
1338 ms |
78300 KB |
Output is correct |
57 |
Correct |
1431 ms |
78456 KB |
Output is correct |
58 |
Execution timed out |
1581 ms |
78532 KB |
Time limit exceeded |
59 |
Halted |
0 ms |
0 KB |
- |