제출 #1336184

#제출 시각아이디문제언어결과실행 시간메모리
1336184AndreyBigger segments (IZhO19_segments)C++20
37 / 100
1592 ms2628 KiB
#include<bits/stdc++.h>
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long n;
    cin >> n;
    vector<long long> haha(n+1);
    for(long long i = 1; i <= n; i++) {
        cin >> haha[i];
    }
    vector<pair<long long,long long>> dp(n+1);
    for(long long i = 1; i <= n; i++) {
        long long sb = 0;
        for(long long j = i; j >= 1; j--) {
            sb+=haha[j];
            if(-dp[j-1].second <= sb) {
                dp[i] = max(dp[i],{dp[j-1].first+1,-sb});
            }
        }
    }
    cout << dp[n].first;
    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...