#include <bits/stdc++.h>
#define REP(i,a,b) for (auto i = (a); i <= (b); ++i)
#define PER(i,a,b) for (auto i = (b); i >= (a); --i)
#define log2(x) (31-__builtin_clz(x))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define SZ(x) (int)(x).size()
#define PB push_back
#define FI first
#define SE second
#define mup(x,y) x = min(x,y)
#define Mup(x,y) x = max(x,y)
#define debug(x) cout << #x << " is " << x << el
#define el '\n'
using namespace std; using ll = long long; using ii = pair<int,int>; using iii = tuple<int,int,int>;
void solution(); int main() {ios::sync_with_stdio(0); cin.tie(0); solution();}
const int N = 200003;
int n, q, a[N], ans[N], cnt;
vector<ii> query, ord;
bool live[N];
void input() {
cin >> n >> q;
REP(i,1,n) {cin >> a[i]; ord.push_back({a[i],i});}
}
void solution() {
input();
REP(i,1,q) {
int x; cin >> x;
if (x&1) {
int b; cin >> b;
query.push_back({b,i});
}
else return;
}
sort(RALL(query));
sort(ALL(ord));
REP(i,0,q-1) {
auto [b,j] = query[i];
while (!ord.empty() && ord.back().first >= b) {
int idx = ord.back().second; ord.pop_back();
live[idx] = true; if (!live[idx-1] && !live[idx+1]) ++cnt;
if (live[idx-1] && live[idx+1]) --cnt;
}
ans[j] = cnt;
}
REP(i,1,q) cout << ans[i] << el;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
460 KB |
Output is correct |
2 |
Correct |
2 ms |
460 KB |
Output is correct |
3 |
Correct |
2 ms |
460 KB |
Output is correct |
4 |
Correct |
11 ms |
1192 KB |
Output is correct |
5 |
Correct |
19 ms |
2116 KB |
Output is correct |
6 |
Correct |
31 ms |
2940 KB |
Output is correct |
7 |
Correct |
48 ms |
4288 KB |
Output is correct |
8 |
Correct |
60 ms |
5272 KB |
Output is correct |
9 |
Correct |
120 ms |
8500 KB |
Output is correct |
10 |
Correct |
88 ms |
8516 KB |
Output is correct |
11 |
Correct |
114 ms |
9680 KB |
Output is correct |
12 |
Correct |
127 ms |
10560 KB |
Output is correct |
13 |
Correct |
125 ms |
10552 KB |
Output is correct |
14 |
Correct |
125 ms |
10488 KB |
Output is correct |
15 |
Correct |
126 ms |
10424 KB |
Output is correct |
16 |
Correct |
132 ms |
10684 KB |
Output is correct |
17 |
Correct |
131 ms |
10764 KB |
Output is correct |
18 |
Correct |
137 ms |
10656 KB |
Output is correct |
19 |
Correct |
129 ms |
10688 KB |
Output is correct |
20 |
Correct |
129 ms |
10808 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |