Submission #1181660

#TimeUsernameProblemLanguageResultExecution timeMemory
1181660NomioBigger segments (IZhO19_segments)C++20
37 / 100
1595 ms3396 KiB
#include<bits/stdc++.h> #define s second #define f first using namespace std; using ll = long long; pair<int, ll> f(pair<int, ll> a, pair<int, ll> b) { if(a.f > b.f) return a; else if(a.f < b.f) return b; else if(a.s < b.s) return a; else return b; } int main() { ios::sync_with_stdio(0); cin.tie(0); int n; cin >> n; vector<ll> a(n + 1), p(n + 1, 0); for(int i = 1; i <= n; i++) { cin >> a[i]; } for(int i = 1; i <= n; i++) { p[i] = p[i - 1] + a[i]; } pair<int, ll> dp[n + 1]; dp[0] = {0, 0}; for(int i = 1; i <= n; i++) { for(int j = 0; j < n; j++) { if(p[i] - p[j] >= dp[j].s) { dp[i] = f(dp[i], {dp[j].f + 1, p[i] - p[j]}); } } } cout << dp[n].f << '\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...