#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#pragma GCC optimize("-Ofast")
//#pragma GCC optimize("trapv")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx2,tune=native")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-funroll-loops")
using namespace std;
using namespace __gnu_pbds;
#define vi vector<int>
#define vll vector<ll>
#define vii vector<pair<int, int>>
#define vvi vector<vi>
#define vvii vector<vii>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define loop(_) for (int __ = 0; __ < (_); ++__)
#define forn(i, n) for (int i = 0; i < n; ++i)
#define pb push_back
#define f first
#define s second
#define sz(_) ((int)_.size())
#define all(_) _.begin(), _.end()
#define uni(_) unique(_)
#define lb lower_bound
#define ub upper_bound
#define si set<int>
#define ms multiset<int>
#define qi queue<int>
#define pq prioriry_queue<int>
#define mi map<int, int>
#define inc(i, l, r) for (int i = l; i <= r; i++)
#define dec(i, l, r) for (int i = l; i >= r; i--)
using lll = __int128;
using ll = long long;
using ld = long double;
const int N = 1e6 + 7;
const ll mod = 1e9 + 7;
const ll inf = 2e18;
auto ra = [] {char *p = new char ; delete p ; return ll(p) ; };
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count() * (ra() | 1));
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> os;
int n;
int a[N];
struct fenwick
{
int bit[N];
fenwick()
{
memset(bit, 0, sizeof bit);
}
void add(int x, int v)
{
for (; x < N; x += x & -x)
bit[x] += v;
}
int upto(int x)
{
int ret = 0;
for (; x; x -= x & -x)
ret += bit[x];
return ret;
}
inline int get(int l, int r)
{
if (l > r)
return 0;
return upto(r) - upto(l - 1);
}
} sum;
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
#ifndef ONLINE_JUDGE
#endif
cin >> n;
for (int i = 0; i < n; ++i)
{
cin >> a[i];
}
int ans = 0;
for (int i = 0; i < n;)
{
int j = i;
while (j + 1 < n && a[j + 1] >= a[j] && sum.get(a[i] + 1, a[j + 1] - 1) == 0)
{
++j;
}
ans++;
while (i <= j)
{
sum.add(a[i], 1);
++i;
}
}
cout << ans;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
4204 KB |
Output is correct |
2 |
Correct |
2 ms |
4204 KB |
Output is correct |
3 |
Correct |
2 ms |
4204 KB |
Output is correct |
4 |
Correct |
3 ms |
4204 KB |
Output is correct |
5 |
Correct |
3 ms |
4204 KB |
Output is correct |
6 |
Correct |
3 ms |
4204 KB |
Output is correct |
7 |
Correct |
3 ms |
4204 KB |
Output is correct |
8 |
Correct |
3 ms |
4204 KB |
Output is correct |
9 |
Correct |
3 ms |
4204 KB |
Output is correct |
10 |
Correct |
2 ms |
4204 KB |
Output is correct |
11 |
Correct |
3 ms |
4204 KB |
Output is correct |
12 |
Correct |
3 ms |
4204 KB |
Output is correct |
13 |
Correct |
3 ms |
4204 KB |
Output is correct |
14 |
Correct |
3 ms |
4204 KB |
Output is correct |
15 |
Correct |
2 ms |
4204 KB |
Output is correct |
16 |
Correct |
3 ms |
4204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
4204 KB |
Output is correct |
2 |
Correct |
2 ms |
4204 KB |
Output is correct |
3 |
Correct |
2 ms |
4204 KB |
Output is correct |
4 |
Correct |
3 ms |
4204 KB |
Output is correct |
5 |
Correct |
3 ms |
4204 KB |
Output is correct |
6 |
Correct |
3 ms |
4204 KB |
Output is correct |
7 |
Correct |
3 ms |
4204 KB |
Output is correct |
8 |
Correct |
3 ms |
4204 KB |
Output is correct |
9 |
Correct |
3 ms |
4204 KB |
Output is correct |
10 |
Correct |
2 ms |
4204 KB |
Output is correct |
11 |
Correct |
3 ms |
4204 KB |
Output is correct |
12 |
Correct |
3 ms |
4204 KB |
Output is correct |
13 |
Correct |
3 ms |
4204 KB |
Output is correct |
14 |
Correct |
3 ms |
4204 KB |
Output is correct |
15 |
Correct |
2 ms |
4204 KB |
Output is correct |
16 |
Correct |
3 ms |
4204 KB |
Output is correct |
17 |
Correct |
3 ms |
4204 KB |
Output is correct |
18 |
Correct |
3 ms |
4204 KB |
Output is correct |
19 |
Correct |
3 ms |
4204 KB |
Output is correct |
20 |
Correct |
3 ms |
4204 KB |
Output is correct |
21 |
Correct |
3 ms |
4204 KB |
Output is correct |
22 |
Correct |
3 ms |
4204 KB |
Output is correct |
23 |
Correct |
3 ms |
4204 KB |
Output is correct |
24 |
Correct |
3 ms |
4204 KB |
Output is correct |
25 |
Correct |
3 ms |
4204 KB |
Output is correct |
26 |
Correct |
3 ms |
4204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
4204 KB |
Output is correct |
2 |
Correct |
2 ms |
4204 KB |
Output is correct |
3 |
Correct |
2 ms |
4204 KB |
Output is correct |
4 |
Correct |
3 ms |
4204 KB |
Output is correct |
5 |
Correct |
3 ms |
4204 KB |
Output is correct |
6 |
Correct |
3 ms |
4204 KB |
Output is correct |
7 |
Correct |
3 ms |
4204 KB |
Output is correct |
8 |
Correct |
3 ms |
4204 KB |
Output is correct |
9 |
Correct |
3 ms |
4204 KB |
Output is correct |
10 |
Correct |
2 ms |
4204 KB |
Output is correct |
11 |
Correct |
3 ms |
4204 KB |
Output is correct |
12 |
Correct |
3 ms |
4204 KB |
Output is correct |
13 |
Correct |
3 ms |
4204 KB |
Output is correct |
14 |
Correct |
3 ms |
4204 KB |
Output is correct |
15 |
Correct |
2 ms |
4204 KB |
Output is correct |
16 |
Correct |
3 ms |
4204 KB |
Output is correct |
17 |
Correct |
3 ms |
4204 KB |
Output is correct |
18 |
Correct |
3 ms |
4204 KB |
Output is correct |
19 |
Correct |
3 ms |
4204 KB |
Output is correct |
20 |
Correct |
3 ms |
4204 KB |
Output is correct |
21 |
Correct |
3 ms |
4204 KB |
Output is correct |
22 |
Correct |
3 ms |
4204 KB |
Output is correct |
23 |
Correct |
3 ms |
4204 KB |
Output is correct |
24 |
Correct |
3 ms |
4204 KB |
Output is correct |
25 |
Correct |
3 ms |
4204 KB |
Output is correct |
26 |
Correct |
3 ms |
4204 KB |
Output is correct |
27 |
Correct |
3 ms |
4224 KB |
Output is correct |
28 |
Correct |
3 ms |
4204 KB |
Output is correct |
29 |
Correct |
3 ms |
4204 KB |
Output is correct |
30 |
Correct |
3 ms |
4204 KB |
Output is correct |
31 |
Correct |
4 ms |
4204 KB |
Output is correct |
32 |
Correct |
3 ms |
4352 KB |
Output is correct |
33 |
Correct |
3 ms |
4204 KB |
Output is correct |
34 |
Correct |
3 ms |
4204 KB |
Output is correct |
35 |
Correct |
3 ms |
4204 KB |
Output is correct |
36 |
Correct |
3 ms |
4204 KB |
Output is correct |
37 |
Correct |
3 ms |
4204 KB |
Output is correct |
38 |
Correct |
3 ms |
4204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
4204 KB |
Output is correct |
2 |
Correct |
2 ms |
4204 KB |
Output is correct |
3 |
Correct |
2 ms |
4204 KB |
Output is correct |
4 |
Correct |
3 ms |
4204 KB |
Output is correct |
5 |
Correct |
3 ms |
4204 KB |
Output is correct |
6 |
Correct |
3 ms |
4204 KB |
Output is correct |
7 |
Correct |
3 ms |
4204 KB |
Output is correct |
8 |
Correct |
3 ms |
4204 KB |
Output is correct |
9 |
Correct |
3 ms |
4204 KB |
Output is correct |
10 |
Correct |
2 ms |
4204 KB |
Output is correct |
11 |
Correct |
3 ms |
4204 KB |
Output is correct |
12 |
Correct |
3 ms |
4204 KB |
Output is correct |
13 |
Correct |
3 ms |
4204 KB |
Output is correct |
14 |
Correct |
3 ms |
4204 KB |
Output is correct |
15 |
Correct |
2 ms |
4204 KB |
Output is correct |
16 |
Correct |
3 ms |
4204 KB |
Output is correct |
17 |
Correct |
3 ms |
4204 KB |
Output is correct |
18 |
Correct |
3 ms |
4204 KB |
Output is correct |
19 |
Correct |
3 ms |
4204 KB |
Output is correct |
20 |
Correct |
3 ms |
4204 KB |
Output is correct |
21 |
Correct |
3 ms |
4204 KB |
Output is correct |
22 |
Correct |
3 ms |
4204 KB |
Output is correct |
23 |
Correct |
3 ms |
4204 KB |
Output is correct |
24 |
Correct |
3 ms |
4204 KB |
Output is correct |
25 |
Correct |
3 ms |
4204 KB |
Output is correct |
26 |
Correct |
3 ms |
4204 KB |
Output is correct |
27 |
Correct |
3 ms |
4224 KB |
Output is correct |
28 |
Correct |
3 ms |
4204 KB |
Output is correct |
29 |
Correct |
3 ms |
4204 KB |
Output is correct |
30 |
Correct |
3 ms |
4204 KB |
Output is correct |
31 |
Correct |
4 ms |
4204 KB |
Output is correct |
32 |
Correct |
3 ms |
4352 KB |
Output is correct |
33 |
Correct |
3 ms |
4204 KB |
Output is correct |
34 |
Correct |
3 ms |
4204 KB |
Output is correct |
35 |
Correct |
3 ms |
4204 KB |
Output is correct |
36 |
Correct |
3 ms |
4204 KB |
Output is correct |
37 |
Correct |
3 ms |
4204 KB |
Output is correct |
38 |
Correct |
3 ms |
4204 KB |
Output is correct |
39 |
Correct |
81 ms |
6508 KB |
Output is correct |
40 |
Correct |
114 ms |
7788 KB |
Output is correct |
41 |
Correct |
55 ms |
6256 KB |
Output is correct |
42 |
Correct |
52 ms |
5996 KB |
Output is correct |
43 |
Correct |
36 ms |
5652 KB |
Output is correct |
44 |
Correct |
142 ms |
8556 KB |
Output is correct |
45 |
Correct |
141 ms |
8556 KB |
Output is correct |
46 |
Correct |
143 ms |
8556 KB |
Output is correct |
47 |
Correct |
129 ms |
8556 KB |
Output is correct |
48 |
Correct |
126 ms |
8556 KB |
Output is correct |
49 |
Correct |
147 ms |
8556 KB |
Output is correct |
50 |
Correct |
143 ms |
8556 KB |
Output is correct |
51 |
Correct |
151 ms |
8556 KB |
Output is correct |
52 |
Correct |
181 ms |
8684 KB |
Output is correct |
53 |
Correct |
166 ms |
8556 KB |
Output is correct |
54 |
Correct |
145 ms |
8556 KB |
Output is correct |
55 |
Correct |
164 ms |
8684 KB |
Output is correct |
56 |
Correct |
222 ms |
8556 KB |
Output is correct |
57 |
Correct |
153 ms |
8556 KB |
Output is correct |
58 |
Correct |
170 ms |
8556 KB |
Output is correct |
59 |
Correct |
173 ms |
8684 KB |
Output is correct |
60 |
Correct |
151 ms |
8684 KB |
Output is correct |
61 |
Correct |
165 ms |
8556 KB |
Output is correct |
62 |
Correct |
158 ms |
8556 KB |
Output is correct |