이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n,str_sum=0;
    cin>>n;
    vector<ll> answers;
    ll all_players[501];
    for(ll i=0;i<n;i++){
        cin>>all_players[i];
        str_sum+=all_players[i];
    }
    if(str_sum%2!=0){cout<<0<<endl; return 0;}
    for(ll i=1;i<=str_sum;i++){
        all_players[n]=i;
        bool is_friendly=true;
        for(ll j=0;j<=n;j++){
            ll new_sum=str_sum+all_players[n]-all_players[j];
            if(new_sum%2!=0){is_friendly=false; break;}
            bool knapsack[3401];
            for(ll x=0;x<3401;x++)knapsack[x]=false;
            knapsack[0]=true;
            for(ll x=0;x<j;x++){
                vector<ll> hold_off;
                for(ll y=0;y<=new_sum/2-all_players[x];y++){
                    if(knapsack[y]){
                        hold_off.push_back(y+all_players[x]);
                    }
                }
                for(ll y=0;y<(ll)hold_off.size();y++){
                    knapsack[hold_off[y]]=true;
                }
            }
            for(ll x=j+1;x<=n;x++){
                vector<ll> hold_off;
                for(ll y=0;y<=new_sum/2-all_players[x];y++){
                    if(knapsack[y]){
                        hold_off.push_back(y+all_players[x]);
                    }
                }
                for(ll y=0;y<(ll)hold_off.size();y++){
                    knapsack[hold_off[y]]=true;
                }
            }
            if(!knapsack[new_sum/2]){
                is_friendly=false;
                break;
            }
        }
        if(is_friendly){
            answers.push_back(i);
        }
    }
    cout<<answers.size()<<endl;
    for(ll i=0;i<(ll)answers.size();i++){
        cout<<answers[i]<<" ";
    }
    cout<<endl;
    return 0;
}
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... |