Submission #526278

#TimeUsernameProblemLanguageResultExecution timeMemory
526278CursedCodeBigger segments (IZhO19_segments)C++14
13 / 100
1 ms684 KiB
#include<bits/stdc++.h> using namespace std; int main(){ int n,i,a[100000],j; cin >> n; for(i = 1;i <= n;i++){ cin >> a[i]; } int dp[n+1],cnt[n+1]; dp[1] = a[1]; dp[0] = 0; cnt[0] = 0; cnt[1] = 1; for(i = 2;i <= n;i++){ int ol = 0; for(j = i;j >= 1;j--){ ol+= a[j]; if(ol >= dp[j-1]){ cnt[i] = cnt[j-1] + 1; break; } } dp[i] = ol; } cout << cnt[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...