Submission #682918

#TimeUsernameProblemLanguageResultExecution timeMemory
682918ToxtaqBigger segments (IZhO19_segments)C++17
13 / 100
660 ms300 KiB
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, mx = 0;
    cin >> n;
    vector<long long>v(n);
    for(int i = 0;i < n;++i)cin >> v[i];
    for(int i = 1;i < (1 << n);i += 2){
        long long temp = 0;
        vector<long long>S;
        for(int j = 0;j < n;++j){
            if(i & (1 << j)){
                temp += v[j];
            }
            else{
                S.push_back(temp);
                temp = v[j];
            }
        }
        S.push_back(temp);
        bool check = 1;
        int sz = S.size();
        for(int j = 1;j < sz && check;++j){
            if(S[j - 1] > S[j])check = 0;
        }
        if(check){
            mx = max(mx, sz);
        }
    }
    cout << mx;
}
#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...