C

#include<bits/stdc++.h>
using namespace std;
int a[10];
int x,y,z;
int main()
{
    int n;
    for (int i = 1;i <= n;i ++) cin >> a[i];
    int max = 0;
    for (int i = 1;i <= n-2;i ++)
    {
        bool flag = false;
        x = 0;
        for (int j = 1;j <= i;j ++) x += a[j];
        for (int k = i + 1;k <= n-1;k ++)
        {
            y = 0;
            for (int q = i + 1;q <= k;q ++) y += a[q];
            for (int l = k + 1;l <= n;l ++)
            {
                z = 0;
                for (int m = k + 1;m <= l;m ++) z += a[m];
                if (x+y<=z||x+z<=y||y+z<=x) 
                {
                    flag = true;
                    break;
                }
            }
            if (flag) break;
        }
    }
    cout << -1;
    return 0;
}

 

上一篇:「codeforces - 1633F」Perfect Matching


下一篇:最大子序列下标(动态规划