Submission #1134963

#TimeUsernameProblemLanguageResultExecution timeMemory
1134963antonnMizuyokan 2 (JOI23_mizuyokan2)C++20
0 / 100
42 ms1352 KiB
#include <bits/stdc++.h> #define F first #define S second using namespace std; using ll = long long; using pi = pair<int, int>; using vi = vector<int>; template<class T> bool ckmin(T& a, T b) { return b < a ? a = b, true : false; } template<class T> bool ckmax(T& a, T b) { return a < b ? a = b, true : false; } const int N = 3e5+7; int d[N]; int solve_0(vector<int> &lens) { // < > < > < > ll sum = 0, ans = 1, last = lens[0]; for (int i = 1; i < lens.size(); ++i) { sum += lens[i]; if (i == lens.size() - 1) { ans += (sum > last); break; } if (sum > last && sum > lens[i + 1]) ans += 2, last = lens[i + 1], ++i, sum = 0; } return ans; } int solve_1(vector<int> &lens) { // > < > < > ll sum = 0, ans = 0, last = 0; for (int i = 0; i < lens.size(); ++i) { sum += lens[i]; if (i == lens.size() - 1) { ans += (sum > last); break; } if (sum > last && sum > lens[i + 1]) ans += 2, last = lens[i + 1], ++i, sum = 0; } return ans; } int main() { ios::sync_with_stdio(0); cin.tie(0); int n; cin >> n; for (int i = 1; i <= n; ++i) cin >> d[i]; int q; cin >> q; for (int i = 1; i <= q; ++i) { int x, y, a, b; cin >> x >> y >> a >> b; d[x] = y; vector<int> lens; for (int j = a + 1; j <= b; ++j) lens.push_back(d[j]); cout << max(solve_0(lens), solve_1(lens)) << "\n"; } }
#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...