Submission #92745

#TimeUsernameProblemLanguageResultExecution timeMemory
92745janchomathBootfall (IZhO17_bootfall)C++14
13 / 100
1082 ms504 KiB
#include<bits/stdc++.h> #define ll int #define f first #define s second #define pb push_back using namespace std; ll n,a[20005],dp[20005],sum,s,oo,x; vector<ll>anss,v; inline bool check(ll k){ v.clear(); s = 0; for(int i=1; i<=n; i++)if(i != k)v.pb(a[i]),s += a[i]; if(s % 2 == 1)return false; for(int i=1; i<=s; i++)dp[i] = 0; dp[0] = 1; for(int i=0; i<v.size(); i++){ for(int j=s; j>=0; j--){ dp[j + v[i]] = max(dp[j],dp[j + v[i]]); if(dp[j + v[i]] && j + v[i] == s/2){ return true; } } } return false; } int main(){ std::ios::sync_with_stdio(false); cin >> n; for(int i=1; i<=n; i++){ cin >> a[i]; sum += a[i]; } n++; for(x=1; x<=sum; x++){ a[n] = x; oo = 0; for(int i=1; i<=n; i++){ if(!check(i)){ oo = 1; break; } } if(!oo){ anss.pb(x); } } cout << anss.size() << endl; for(int i=0; i<anss.size(); i++)cout << anss[i] << " "; return 0; }

Compilation message (stderr)

bootfall.cpp: In function 'bool check(int)':
bootfall.cpp:19:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0; i<v.size(); i++){
               ~^~~~~~~~~
bootfall.cpp: In function 'int main()':
bootfall.cpp:64:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0; i<anss.size(); i++)cout << anss[i] << " ";
               ~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...