#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using ld = long double;
//#define int ll
#define sz(x) ((int)(x).size())
using pii = pair<int,int>;
using tii = tuple<int,int,int>;
int check(vector<int>& v, int p, int l, int r) {
priority_queue<pii, vector<pii>, greater<pii>> heap;
heap.emplace(v[p - 1], p - 1);
heap.emplace(v[p + 1], p + 1);
int S = v[p];
while(!heap.empty()) {
auto [C, poz] = heap.top();
heap.pop();
if(poz > r || poz < l) continue;
if(S < C) return 0;
//cerr << S << ' ' << C << '\t' << p << ' ' << poz << '\n';
S += C;
if(p < poz) heap.emplace(v[poz + 1], poz + 1);
if(p > poz) heap.emplace(v[poz - 1], poz - 1);
}
return 1;
}
signed main() {
cin.tie(0) -> sync_with_stdio(0);
int n, q;
cin >> n;
vector<int> v(n + 1);
for(int i = 1; i <= n; i++) cin >> v[i];
cin >> q;
v.emplace_back(0);
for(int TC = 0, t, x, y; TC < q; TC++) {
cin >> t >> x >> y;
if(t == 1)
v[x] = y;
else {
int cnt = 0;
for(int i = x; i <= y; i++)
cnt += check(v, i, x, y);
cout << cnt << '\n';
}
}
}
/**
Anul asta nu se da centroid
-- Rugaciunile mele
*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Incorrect |
15 ms |
468 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Incorrect |
41 ms |
1116 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Incorrect |
15 ms |
468 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Incorrect |
41 ms |
1116 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Incorrect |
41 ms |
1116 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Incorrect |
15 ms |
468 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |