Submission #860485

#TimeUsernameProblemLanguageResultExecution timeMemory
860485AlfraganusBigger segments (IZhO19_segments)C++14
37 / 100
1561 ms3164 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define endl '\n' #define fs first #define ss second #define str string #define all(a) a.begin(), a.end() #define print(a) \ for (auto x : a) \ cout << x << ' '; \ cout << endl; #define each(x, a) for (auto x : a) struct node { int s, l, r; }; void solve() { int n; cin >> n; vector<int> a(n); for(int i = 0; i < n; i ++) cin >> a[i]; vector<int> dp(n + 1), sum(n + 1); for(int i = 0; i < n; i ++){ int s = 0; for(int j = i; j >= 0; j --){ s += a[j]; if(sum[j] <= s){ dp[i + 1] = dp[j] + 1; sum[i + 1] = s; break; } } } cout << dp[n]; } signed main() { ios::sync_with_stdio(0); cin.tie(0); int t = 1; // cin >> t; while (t--) { solve(); cout << endl; } }
#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...