Submission #603254

#TimeUsernameProblemLanguageResultExecution timeMemory
603254OzyBigger segments (IZhO19_segments)C++17
37 / 100
5 ms468 KiB
#include <iostream> #include <bits/stdc++.h> using namespace std; #define lli long long int #define rep(i,a,b) for (int i = (a); i <= (b);i++) #define repa(i,a,b) for (int i = (a); i >= (b);i--) #define debug(a) cout << #a << " = " << a << endl #define debugsl(a) cout << #a << " = " << a << ", " #define MAX 3000 #define val first #define res second lli n,sum; lli arr[MAX+2]; pair<lli,lli> dp[MAX+2]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n; rep(i,1,n) cin >> arr[i]; rep(i,1,n) { sum = arr[i]; repa(j,i-1,0) { if (dp[j].val <= sum) { dp[i].val = sum; dp[i].res = dp[j].res + 1; break; } sum += arr[j]; } } cout << dp[n].res; }
#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...