Submission #36181

#TimeUsernameProblemLanguageResultExecution timeMemory
36181ToMoCloneBootfall (IZhO17_bootfall)C++14
100 / 100
679 ms6976 KiB
/*input 4 1 3 1 5 */ #include <stdio.h> #include <vector> using namespace std; const int N = 501; int check[N * N], cnt[250001], num[1000001], a[N], n, sum, ans; int main(){ scanf("%d", &n); check[0] = 1; for(int i = 1; i <= n; ++i){ scanf("%d", &a[i]), sum += a[i]; for(int j = sum; j >= a[i]; --j) check[j] += check[j - a[i]]; } if((sum & 1) || check[sum >> 1] == 0) return puts("0"), 0; for(int i = 1; i <= n; ++i){ for(int j = 0; j <= sum - a[i]; ++j) check[j + a[i]] -= check[j]; for(int j = 1; j <= sum; ++j){ int Sum = sum + j - a[i]; if((Sum & 1) || ((Sum >> 1) < j)) continue; if(check[Sum >> 1] != 0 && check[(Sum >> 1) - j] != 0) ++num[j]; ans += (num[j] == n); } for(int j = sum; j >= a[i]; --j) check[j] += check[j - a[i]]; } printf("%d\n", ans); if(ans != 0){ for(int i = 1; i <= sum; ++i) if(num[i] == n) printf("%d ", i); puts(""); } }

Compilation message (stderr)

bootfall.cpp: In function 'int main()':
bootfall.cpp:13:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
                 ^
bootfall.cpp:17:34: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &a[i]), sum += 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...