Submission #337937

#TimeUsernameProblemLanguageResultExecution timeMemory
337937kutbilim_oneBootfall (IZhO17_bootfall)C++14
0 / 100
1 ms364 KiB
/** kutbilim.one **/ #include <bits/stdc++.h> using namespace std; #define all(x) x.begin(),x.end() //#define int long long #define endl '\n' /* ifstream in("test.txt"); #define cin in */ int main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; int a[n]; int sum = 0; for(int i = 0; i < n; i++) cin >> a[i], sum += a[i]; sort(a, a+n); int MAX = sum; int dp[MAX+1]; short used[MAX+1]; dp[0] = 1; for(int k = 0; k < n; k++){ for(int x = MAX-a[k]; x >= 0; x--){ dp[x+a[k]] += dp[x]; } } if(sum%2 == 1 || dp[sum/2] == 0) return cout << 0, 0; for(int ex = 0; ex < n; ex++){ int left = sum-a[ex]; for(int x = 0; x <= left; x++) dp[x + a[ex]] -= dp[x]; for(int right = 0; right <= MAX; right++) if((left+right)%2 == 1 || dp[(left+right)/2] == 0) used[right] = 1; for(int x = left; x >= 0; x--) dp[x + a[ex]] += dp[x]; } vector<int> res; for(int i = 0; i <= MAX; i++){ if(!used[i]) res.push_back(i); } cout << res.size() << endl; for(auto i : res) cout << i << " "; return 0; }

Compilation message (stderr)

bootfall.cpp: In function 'int main()':
bootfall.cpp:42:9: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   42 |         for(int right = 0; right <= MAX; right++)
      |         ^~~
bootfall.cpp:45:6: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   45 |      for(int x = left; x >= 0; x--)
      |      ^~~
#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...