제출 #373998

#제출 시각아이디문제언어결과실행 시간메모리
373998mariowongBigger segments (IZhO19_segments)C++14
0 / 100
1 ms364 KiB
#include <bits/stdc++.h> using namespace std; long long n,a[3005]; pair <long long,long long> dp[3005]; long long ps[3005],ans; int main(){ ios::sync_with_stdio(false); cin >> n; for (int i=1;i<=n;i++){ cin >> a[i]; ps[i]=ps[i-1]+a[i]; } for (int i=1;i<=n;i++){ dp[i]=make_pair(ps[i],1); for (int j=1;j<i;j++){ if (ps[i]-dp[j].first > dp[j].first && (dp[j].second+1 > dp[i].second || (dp[i].second+1 == dp[j].second && ps[i]-dp[j].first < dp[i].first))) dp[i]=make_pair(ps[i]-dp[j].first,dp[j].second+1); } } cout << dp[n].second << "\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...