Submission #36173

#TimeUsernameProblemLanguageResultExecution timeMemory
36173ToMoCloneBootfall (IZhO17_bootfall)C++14
44 / 100
1000 ms6524 KiB
/*input 4 1 3 1 5 */ #include <stdio.h> #include <vector> using namespace std; const int N = 501; int check[N * N], cnt[1000001], Lol[501], a[N], n, sum; 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(cnt[a[i]] == 1) Lol[i] = 1; else ++cnt[a[i]]; } if((sum & 1) || check[sum >> 1] == 0) return puts("0"), 0; vector<int> ans; for(int i = 1; i <= sum; ++i){ int Sum = sum + i, ok = 1; for(int j = 1; j <= n; ++j){ if(Lol[j]) continue; if(ok == 0 || ((Sum - a[j]) & 1) || (((Sum - a[j]) >> 1) < i)) { ok = 0; break; } int A = 0, sign = 1; for(int k = ((Sum - a[j]) >> 1) - i; k >= 0; k -= a[j]) if(sign) A += check[k], sign ^= 1; else A -= check[k], sign ^= 1; if(A == 0) ok = 0; } if(ok) ans.push_back(i); } printf("%d\n", (int)ans.size()); if(ans.size()) for(int i = 0; i < (int)ans.size(); ++i) printf("%d ", ans[i]); printf("\n"); }

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...