제출 #522638

#제출 시각아이디문제언어결과실행 시간메모리
522638nafis_shifatBigger segments (IZhO19_segments)C++17
37 / 100
1574 ms3372 KiB
#include<bits/stdc++.h> #define ll long long #define pii pair<ll,ll> using namespace std; const int mxn=1e5+5; const int inf=1e9; pii dp[mxn]; ll a[mxn], pre[mxn]; int n; int main() { cin >> n; pre[0] = 0; for(int i = 1; i <= n; i++) { cin >> a[i]; pre[i] = pre[i - 1] + a[i]; } dp[0] = {0, 0}; for(int i = 1; i <= n; i++) { dp[i] = {1, -pre[i]}; for(int j = i - 1; j >= 1; j--) { if(pre[i] - pre[j] >= -dp[j].second) { dp[i] = max(dp[i], make_pair(dp[j].first + 1, -pre[i] + pre[j])); } } } cout<<dp[n].first<<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...