Submission #1055080

#TimeUsernameProblemLanguageResultExecution timeMemory
1055080MilosMilutinovicMizuyokan 2 (JOI23_mizuyokan2)C++14
15 / 100
4088 ms6740 KiB
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } int q; cin >> q; while (q--) { int x, y, l, r; cin >> x >> y >> l >> r; --x; --r; a[x] = y; vector<long long> pref(n); for (int i = 0; i < n; i++) { pref[i] = (i == 0 ? 0LL : pref[i - 1]) + a[i]; } auto Get = [&](int l, int r) { return pref[r] - (l == 0 ? 0LL : pref[l - 1]); }; vector<int> dp(n); dp[l] = 1; int res = 1; for (int i = l + 1; i <= r; i++) { for (int j = l; j < i; j++) { long long s = Get(j, i - 1); if (s > a[i] && (j == l || s > a[j - 1])) { dp[i] = max(dp[i], (j == l ? 0 : dp[j - 1]) + 2); } } } res = max(res, dp[r]); for (int i = l; i < r; i++) { if (a[i] < Get(i + 1, r)) { res = max(res, dp[i] + 1); } } cout << res << '\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...