답안 #1029937

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1029937 2024-07-21T14:10:17 Z andrewp Bootfall (IZhO17_bootfall) C++14
13 / 100
41 ms 6412 KB
#include <bits/stdc++.h>

using namespace std;

#define ll int64_t
#define ar array
#define dbg(x) cerr << #x << ": " << x << "\n";

const int mxN=503;

ll n, a[mxN], dp[mxN*mxN][2], brM[mxN*mxN];

int main() {
    ios::sync_with_stdio(0);
	cin.tie(0);

    cin >> n;
    ll sum=0;
    for(ll i=1; i<=n; ++i) {
        cin >> a[i];
        sum+=a[i];
    }
    for(int i=0; i<mxN*mxN; ++i) {
        for(int j=0; j<2; ++j) {
            dp[i][j]=0;
        }
        brM[i]=0;
    }
    dp[0][0]=1;
    for(ll i=1; i<=n; ++i) {
        for(ll s=mxN*mxN-1; s>=a[i]; --s) {
            dp[s][0]+=dp[s-a[i]][0];
        }
    }
    if(sum%2==1) {
        cout << 0 << "\n";
        return 0;
    }
    if(dp[sum/2][0]==0) {
        cout << 0 << "\n";
        return 0;
    }
    vector<ll> ans;
    for(ll i=1; i<=n; ++i) {
        for(ll s=0; s<mxN*mxN; ++s) {
            dp[s][1]=dp[s][0];
        }
        for(ll s=0; s<mxN*mxN-a[i]; ++s) {
            dp[s+a[i]][1]-=dp[s][1];
        }
        for(ll s=0; s<mxN*mxN; ++s) {
            ll get=s+sum-a[i];
            if((get%2==0)&&(get/2>=s)&&(dp[get/2-s][1]>0)) {
                ++brM[s];
                if(brM[s]==n) ans.push_back(s);
            }
        }
    }
    cout << ans.size() << "\n";
    for(ll x:ans) cout << x << " ";
    cout << "\n";
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 6348 KB Output is correct
2 Correct 8 ms 6236 KB Output is correct
3 Correct 4 ms 6236 KB Output is correct
4 Correct 5 ms 6236 KB Output is correct
5 Correct 11 ms 6236 KB Output is correct
6 Correct 7 ms 6236 KB Output is correct
7 Correct 9 ms 6356 KB Output is correct
8 Correct 10 ms 6408 KB Output is correct
9 Correct 8 ms 6236 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 6348 KB Output is correct
2 Correct 8 ms 6236 KB Output is correct
3 Correct 4 ms 6236 KB Output is correct
4 Correct 5 ms 6236 KB Output is correct
5 Correct 11 ms 6236 KB Output is correct
6 Correct 7 ms 6236 KB Output is correct
7 Correct 9 ms 6356 KB Output is correct
8 Correct 10 ms 6408 KB Output is correct
9 Correct 8 ms 6236 KB Output is correct
10 Correct 23 ms 6236 KB Output is correct
11 Correct 24 ms 6236 KB Output is correct
12 Correct 18 ms 6232 KB Output is correct
13 Correct 24 ms 6352 KB Output is correct
14 Correct 23 ms 6376 KB Output is correct
15 Correct 18 ms 6236 KB Output is correct
16 Correct 17 ms 6412 KB Output is correct
17 Correct 14 ms 6232 KB Output is correct
18 Correct 15 ms 6236 KB Output is correct
19 Correct 17 ms 6332 KB Output is correct
20 Correct 20 ms 6232 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 6348 KB Output is correct
2 Correct 8 ms 6236 KB Output is correct
3 Correct 4 ms 6236 KB Output is correct
4 Correct 5 ms 6236 KB Output is correct
5 Correct 11 ms 6236 KB Output is correct
6 Correct 7 ms 6236 KB Output is correct
7 Correct 9 ms 6356 KB Output is correct
8 Correct 10 ms 6408 KB Output is correct
9 Correct 8 ms 6236 KB Output is correct
10 Correct 23 ms 6236 KB Output is correct
11 Correct 24 ms 6236 KB Output is correct
12 Correct 18 ms 6232 KB Output is correct
13 Correct 24 ms 6352 KB Output is correct
14 Correct 23 ms 6376 KB Output is correct
15 Correct 18 ms 6236 KB Output is correct
16 Correct 17 ms 6412 KB Output is correct
17 Correct 14 ms 6232 KB Output is correct
18 Correct 15 ms 6236 KB Output is correct
19 Correct 17 ms 6332 KB Output is correct
20 Correct 20 ms 6232 KB Output is correct
21 Correct 33 ms 6400 KB Output is correct
22 Incorrect 41 ms 6236 KB Output isn't correct
23 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 6348 KB Output is correct
2 Correct 8 ms 6236 KB Output is correct
3 Correct 4 ms 6236 KB Output is correct
4 Correct 5 ms 6236 KB Output is correct
5 Correct 11 ms 6236 KB Output is correct
6 Correct 7 ms 6236 KB Output is correct
7 Correct 9 ms 6356 KB Output is correct
8 Correct 10 ms 6408 KB Output is correct
9 Correct 8 ms 6236 KB Output is correct
10 Correct 23 ms 6236 KB Output is correct
11 Correct 24 ms 6236 KB Output is correct
12 Correct 18 ms 6232 KB Output is correct
13 Correct 24 ms 6352 KB Output is correct
14 Correct 23 ms 6376 KB Output is correct
15 Correct 18 ms 6236 KB Output is correct
16 Correct 17 ms 6412 KB Output is correct
17 Correct 14 ms 6232 KB Output is correct
18 Correct 15 ms 6236 KB Output is correct
19 Correct 17 ms 6332 KB Output is correct
20 Correct 20 ms 6232 KB Output is correct
21 Correct 33 ms 6400 KB Output is correct
22 Incorrect 41 ms 6236 KB Output isn't correct
23 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 6348 KB Output is correct
2 Correct 8 ms 6236 KB Output is correct
3 Correct 4 ms 6236 KB Output is correct
4 Correct 5 ms 6236 KB Output is correct
5 Correct 11 ms 6236 KB Output is correct
6 Correct 7 ms 6236 KB Output is correct
7 Correct 9 ms 6356 KB Output is correct
8 Correct 10 ms 6408 KB Output is correct
9 Correct 8 ms 6236 KB Output is correct
10 Correct 23 ms 6236 KB Output is correct
11 Correct 24 ms 6236 KB Output is correct
12 Correct 18 ms 6232 KB Output is correct
13 Correct 24 ms 6352 KB Output is correct
14 Correct 23 ms 6376 KB Output is correct
15 Correct 18 ms 6236 KB Output is correct
16 Correct 17 ms 6412 KB Output is correct
17 Correct 14 ms 6232 KB Output is correct
18 Correct 15 ms 6236 KB Output is correct
19 Correct 17 ms 6332 KB Output is correct
20 Correct 20 ms 6232 KB Output is correct
21 Correct 33 ms 6400 KB Output is correct
22 Incorrect 41 ms 6236 KB Output isn't correct
23 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 6348 KB Output is correct
2 Correct 8 ms 6236 KB Output is correct
3 Correct 4 ms 6236 KB Output is correct
4 Correct 5 ms 6236 KB Output is correct
5 Correct 11 ms 6236 KB Output is correct
6 Correct 7 ms 6236 KB Output is correct
7 Correct 9 ms 6356 KB Output is correct
8 Correct 10 ms 6408 KB Output is correct
9 Correct 8 ms 6236 KB Output is correct
10 Correct 23 ms 6236 KB Output is correct
11 Correct 24 ms 6236 KB Output is correct
12 Correct 18 ms 6232 KB Output is correct
13 Correct 24 ms 6352 KB Output is correct
14 Correct 23 ms 6376 KB Output is correct
15 Correct 18 ms 6236 KB Output is correct
16 Correct 17 ms 6412 KB Output is correct
17 Correct 14 ms 6232 KB Output is correct
18 Correct 15 ms 6236 KB Output is correct
19 Correct 17 ms 6332 KB Output is correct
20 Correct 20 ms 6232 KB Output is correct
21 Correct 33 ms 6400 KB Output is correct
22 Incorrect 41 ms 6236 KB Output isn't correct
23 Halted 0 ms 0 KB -