Submission #315307

#TimeUsernameProblemLanguageResultExecution timeMemory
315307dolphingarlicBootfall (IZhO17_bootfall)C++14
44 / 100
1024 ms760 KiB
#include <bits/stdc++.h> #pragma GCC optimize("unroll-loops") using namespace std; int main() { int n, a[500], tot = 0; scanf("%d", &n); bitset<250001> base; base[0] = 1; for (int i = 0; i < n; i++) { scanf("%d", a + i); tot += a[i]; base |= base << a[i]; } if ((tot & 1) || !base[tot >> 1]) return printf("0"), 0; bitset<250001> ans; for (int i = 1; i < 250001; i++) ans[i] = 1; for (int i = 0; i < n; i++) { bitset<250001> possible, good; possible[0] = 1; for (int j = 0; j < n; j++) if (j != i) possible |= possible << a[j]; for (int j = 1; j < 250001; j++) good[j] = !(tot - a[i] + j & 1) && (tot - a[i] + j >> 1) >= j && possible[(tot - a[i] + j >> 1) - j]; ans &= good; } printf("%d\n", ans.count()); for (int i = 0; i < 250001; i++) if (ans[i]) printf("%d ", i); return 0; }

Compilation message (stderr)

bootfall.cpp: In function 'int main()':
bootfall.cpp:24:65: warning: suggest parentheses around '+' in operand of '&' [-Wparentheses]
   24 |         for (int j = 1; j < 250001; j++) good[j] = !(tot - a[i] + j & 1) && (tot - a[i] + j >> 1) >= j && possible[(tot - a[i] + j >> 1) - j];
      |                                                      ~~~~~~~~~~~^~~
bootfall.cpp:24:89: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   24 |         for (int j = 1; j < 250001; j++) good[j] = !(tot - a[i] + j & 1) && (tot - a[i] + j >> 1) >= j && possible[(tot - a[i] + j >> 1) - j];
      |                                                                              ~~~~~~~~~~~^~~
bootfall.cpp:24:128: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   24 |         for (int j = 1; j < 250001; j++) good[j] = !(tot - a[i] + j & 1) && (tot - a[i] + j >> 1) >= j && possible[(tot - a[i] + j >> 1) - j];
      |                                                                                                                     ~~~~~~~~~~~^~~
bootfall.cpp:28:14: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::size_t' {aka 'long unsigned int'} [-Wformat=]
   28 |     printf("%d\n", ans.count());
      |             ~^     ~~~~~~~~~~~
      |              |              |
      |              int            std::size_t {aka long unsigned int}
      |             %ld
bootfall.cpp:7:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    7 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
bootfall.cpp:11:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   11 |         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...