| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1326434 | lopkus | Fish 2 (JOI22_fish2) | C++20 | 7 ms | 568 KiB |
#include <bits/stdc++.h>+
signed main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int n;
std::cin >> n;
std::vector<int> a(n + 1);
for(int i = 1; i <= n; i++) {
std::cin >> a[i];
}
int q;
std::cin >> q;
while(q--) {
int type;
std::cin >> type;
if(type == 1) {
int pos, x;
std::cin >> pos >> x;
a[pos] = x;
}
else {
int L, R;
std::cin >> L >> R;
int ans = 0;
for(int i = L; i <= R; i++) {
int l = i - 1, r = i + 1;
int val = a[i];
while(l >= L || r <= R) {
if(l >= L && a[l] <= val) {
val += a[l--];
continue;
}
if(r <= R && a[r] <= val) {
val += a[r++];
continue;
}
break;
}
if(l < L && r > R) {
ans += 1;
}
}
std::cout << ans << "\n";
}
}
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
