Submission #95501

#TimeUsernameProblemLanguageResultExecution timeMemory
95501choikiwonBootfall (IZhO17_bootfall)C++17
44 / 100
1072 ms988 KiB
#include<bits/stdc++.h> using namespace std; const int MN = 502; int N; int A[MN]; bitset<MN * MN> dp; int cnt[MN * MN]; int main() { scanf("%d", &N); int sum = 0; for(int i = 0; i < N; i++) { scanf("%d", &A[i]); sum += A[i]; } if(sum % 2) { printf("0"); return 0; } dp[0] = 1; for(int i = 0; i < N; i++) { dp |= (dp << A[i]); } if(!dp[sum / 2]) { printf("0"); return 0; } for(int x = 0; x < N; x++) { dp.reset(); dp[0] = 1; for(int i = 0; i < N; i++) { if(i == x) continue; dp |= (dp << A[i]); } for(int i = 0; i < MN * MN; i++) { if(dp[i] && 2 * i + A[x] - sum >= 0) { cnt[ 2 * i + A[x] - sum ]++; } } } int ans = 0; for(int i = 0; i < MN * MN; i++) { if(cnt[i] == N) { ans++; } } printf("%d\n", ans); for(int i = 0; i < MN * MN; i++) { if(cnt[i] == N) { printf("%d ", i); } } }

Compilation message (stderr)

bootfall.cpp: In function 'int main()':
bootfall.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &N);
     ~~~~~^~~~~~~~~~
bootfall.cpp:16:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &A[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...