Submission #877457

# Submission time Handle Problem Language Result Execution time Memory
877457 2023-11-23T08:49:41 Z prince Bootfall (IZhO17_bootfall) C++17
6 / 100
1000 ms 660 KB
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
ll rec(int n,vector<int>&vec,int sum1,int sum2){
    if(n==0){
        return abs(sum1-sum2);
    }
    int a=rec(n-1,vec,sum1+vec[n-1],sum2);
    int b=rec(n-1,vec,sum1,sum2+vec[n-1]);
    return min(a,b);
}
void solve(){
    int n;cin>>n;
    vector<int>vec(n);
    set<int>st;
    sort(vec.begin(),vec.end());
    if(n%2&&vec[0]==vec[vec.size()-1]){
        cout<<0;
        return;
    }
    for(auto &x:vec)cin>>x;
    for(ll i=0;i<n;i++){
        for(ll j=1;j<=1e3;j++){
            bool check=1;
            for(ll k=0;k<n;k++){
                ll l=vec[k];
                vec[k]=j;
                //cout<<l<<" ";
                ll ans=rec(n,vec,0,0);
                vec[k]=l;
                if(ans!=0){
                    check=0;
                    break;
                }
            }
            if(check){
                //cout<<j<<" ";
                st.insert(j);
            }
        }
    }
    cout<<st.size()<<endl;
    for(auto &x:st)cout<<x<<" ";
}
signed main() {
    cin.tie(0)->sync_with_stdio(false);
#ifdef prince
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int q = 1;
    // cin >> q;
    while (q--) {
        solve();
        cout << '\n';
    }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 319 ms 448 KB Output is correct
6 Correct 5 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 335 ms 444 KB Output is correct
9 Correct 31 ms 660 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 319 ms 448 KB Output is correct
6 Correct 5 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 335 ms 444 KB Output is correct
9 Correct 31 ms 660 KB Output is correct
10 Execution timed out 1053 ms 348 KB Time limit exceeded
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 319 ms 448 KB Output is correct
6 Correct 5 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 335 ms 444 KB Output is correct
9 Correct 31 ms 660 KB Output is correct
10 Execution timed out 1053 ms 348 KB Time limit exceeded
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 319 ms 448 KB Output is correct
6 Correct 5 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 335 ms 444 KB Output is correct
9 Correct 31 ms 660 KB Output is correct
10 Execution timed out 1053 ms 348 KB Time limit exceeded
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 319 ms 448 KB Output is correct
6 Correct 5 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 335 ms 444 KB Output is correct
9 Correct 31 ms 660 KB Output is correct
10 Execution timed out 1053 ms 348 KB Time limit exceeded
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 319 ms 448 KB Output is correct
6 Correct 5 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 335 ms 444 KB Output is correct
9 Correct 31 ms 660 KB Output is correct
10 Execution timed out 1053 ms 348 KB Time limit exceeded
11 Halted 0 ms 0 KB -