Submission #84632

# Submission time Handle Problem Language Result Execution time Memory
84632 2018-11-16T08:02:39 Z muradeyn Bootfall (IZhO17_bootfall) C++14
0 / 100
2 ms 632 KB
/* Murad Eynizade */

#include <bits/stdc++.h>
#define intt long long
#define FAST_READ ios_base::sync_with_stdio(0);cin.tie(0);
#define SIZE 100001
#define INF INT_MAX
#define F first
#define S second
#define in(a) scanf("%d",&a);
#define outn(a) printf("%d\n",&a);
#define outs(a) printf("%d ",&a);
#define MOD 1000000007

using namespace std;

bool dp[250005] , f;

int sum , mx;

map<int,int>mp,mp1;

map<int,int>::iterator it;

int main()
{
    FAST_READ;
    int n;
    cin>>n;
    int a[n];
    for (int i = 0;i<n;i++)cin>>a[i] , sum += a[i];
    dp[0] = true;
    for (int i = 0;i<n;i++)
        for (int j = sum;j >= a[i];j--)
            dp[j] |= dp[j - a[i]];
    if (sum % 2) {
        cout<<0<<endl;
        return 0;
    }
    for (int i = 1;i<sum;i++)  {
        if (dp[i] && i == sum / 2) {
            f = true;
            break;
        }
    }
    if (!f) {
        cout<<0<<endl;
        return 0;
    }
    for (int no = 1;no<=n;no++) {
        mx = -1;
        int oldsum = sum;
        sum -= a[no - 1];
        memset(dp,0,sizeof(dp));
        dp[0] = true;
        for (int i = 0;i<n;i++) {
            if (i == no - 1)continue;
            for (int j = sum;j >= a[i];j--)
                dp[j] |= dp[j - a[i]];
        }
        for (int i = 1;i<=sum;i++) {
            if (dp[i] && mp1[abs(i - (sum - i))] != no) {
                //cout<<i<<" "<<abs(i - (sum - i))<<endl;
            }
        }
        if (mx < no) {
            cout<<0<<endl;
            return 0;
        }
        sum = oldsum;
    }
    cout<<0<<endl;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 632 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 632 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 632 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 632 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 632 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 632 KB Output isn't correct
2 Halted 0 ms 0 KB -