제출 #1336307

#제출 시각아이디문제언어결과실행 시간메모리
1336307aaaaaaaaBigger segments (IZhO19_segments)C++20
27 / 100
1589 ms468 KiB
#include <bits/stdc++.h>
using namespace std;
#define int long long

const int inf = 2e18;

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr); cout.tie(nullptr);

    int n, ans = 0;
    cin >> n;

    vector<int> a(n + 1, 0);
    
    for(int i = 1; i <= n; ++i){
        cin >> a[i];
    }

    vector<int> pdp(n + 1, inf);
    pdp[0] = 0;


    for(int k = 1; k <= n; ++k){
        vector<int> ndp(n + 2, inf);
        for(int i = 1; i <= n; ++i){
            for(int j = i, s = 0; j >= 1; --j){
                s += a[j];
                if(s >= pdp[j - 1]){
                    ndp[i] = s;
                    break;
                }
            }
            if(ndp[i] < inf) ans = max(ans, k);
        }
        swap(ndp, pdp);
    }

    cout << ans << "\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...