Submission #842088

#TimeUsernameProblemLanguageResultExecution timeMemory
842088hentai_loverBigger segments (IZhO19_segments)C++14
37 / 100
1540 ms2652 KiB
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); int n; cin>>n; int a[n]; for(int i = 0; i < n; i += 1)cin>>a[i]; ///dp[p] = {ans, min_sum} pair<int,long long> dp[n]; long long sum = 0; for(int i = 0; i < n; i += 1){ sum += a[i]; dp[i] = {1, -sum}; } for(int i = 1; i < n; i += 1){ sum = 0; for(int j = i - 1; j >= 0; j -= 1){ sum += a[j + 1]; if(-dp[j].second <= sum)dp[i] = max(dp[i], {dp[j].first + 1, -sum}); } } int ans = 0; for(int i = 0; i < n; i += 1){ ans = max(ans, dp[i].first); } 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...