Submission #710296

#TimeUsernameProblemLanguageResultExecution timeMemory
710296PixelCatFish 2 (JOI22_fish2)C++14
5 / 100
25 ms2644 KiB
#include <bits/stdc++.h> #define For(i, a, b) for(int i = a; i <= b; i++) #define Forr(i, a, b) for(int i = a; i >= b; i--) #define F first #define S second #define all(x) x.begin(), x.end() #define sz(x) ((int)x.size()) #define eb emplace_back #define int LL using namespace std; using LL = long long; using pii = pair<int, int>; const int MAXN = 100010; int a[MAXN]; int32_t main() { ios::sync_with_stdio(false); cin.tie(0); // =^-w-^= int n; cin >> n; For(i, 1, n) cin >> a[i]; int q; cin >> q; assert(max(n, q) <= 500); while(q--) { int op; cin >> op; int L, R; cin >> L >> R; if(op == 1) { a[L] = R; continue; } int ans = 0; For(s, L, R) { int l, r; l = r = s; int sum = a[s]; bool upd = true; while(upd) { upd = false; if(l > L && sum >= a[l - 1]) { l--; sum += a[l]; upd = true; } else if(r < R && sum >= a[r + 1]) { r++; sum += a[r]; upd = true; } } if(l == L && r == R) ans++; } cout << ans << "\n"; } return 0; }
#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...