Submission #755198

#TimeUsernameProblemLanguageResultExecution timeMemory
755198LucppMizuyokan 2 (JOI23_mizuyokan2)C++17
28 / 100
4073 ms9260 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int DIST = 60; int solve(vector<ll> v){ int n = (int)v.size(); vector<int> dp(n); dp[0] = 1; for(int i = 1; i < n; i++){ ll sum = 0; for(int j = i-1; j >= max(0, i-DIST); j--){ sum += v[j]; if(sum > v[i]){ if(j == 0) dp[i] = max(dp[i], 2); else if(sum > v[j-1]) dp[i] = max(dp[i], dp[j-1] + 2); } } } int ans = max(1, dp[n-1]); ll sum = 0; for(int i = n-1; i >= 1; i--){ sum += v[i]; if(sum > v[i-1]) ans = max(ans, dp[i-1]+1); } return ans; } int main(){ ios_base::sync_with_stdio(false); cin.tie(0); int n, Q; cin >> n; vector<ll> v(n); for(int i = 0; i < n; i++) cin >> v[i]; cin >> Q; for(int q = 0; q < Q; q++){ int x, a, b; ll y; cin >> x >> y >> a >> b; x--; v[x] = y; vector<ll> w; for(int i = a; i < b; i++) w.push_back(v[i]); cout << solve(w) << "\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...