Submission #1029658

#TimeUsernameProblemLanguageResultExecution timeMemory
1029658mansurFish 2 (JOI22_fish2)C++17
5 / 100
4064 ms1628 KiB
#include<bits/stdc++.h> using namespace std; #define rall(s) s.rbegin() s.rend() #define all(s) s.begin(), s.end() #define sz(s) (int)s.size() #define s second #define f first using ll = long long; using pii = pair<int, int>; using pll = pair<ll, ll>; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n; cin >> n; int a[n + 1]; for (int i= 1; i <= n; i++) cin >> a[i]; int q; cin >> q; while (q--) { int tp; cin >> tp; if (tp == 1) { int x, y; cin >> x >> y; a[x] = y; }else { int l, r; cin >> l >> r; int ans = 0; for (int i = l; i <= r; i++) { ll sum = a[i]; int tl = i - 1, tr = i + 1, ok = 1; while (tl >= l || tr <= r) { if (tl >= l && sum >= a[tl]) { sum += a[tl]; tl--; continue; } if (tr <= r && sum >= a[tr]) { sum += a[tr]; tr++; continue; } ok = 0; break; } ans += ok; } cout << ans << ' '; } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...