Submission #166684

#TimeUsernameProblemLanguageResultExecution timeMemory
166684abilBootfall (IZhO17_bootfall)C++14
13 / 100
1068 ms620 KiB
#include <bits/stdc++.h> #define fr first #define sc second #define pb push_back #define mk make_pair #define all(s) s.begin(),s.end() //#define int long long using namespace std; const int N = (1e6 + 12); const int mod = (1e9 + 7); const int INF = (0x3f3f3f3f); int a[N]; set<int > s; main() { int n, sum = 0; scanf("%d", &n); for(int i = 0;i < n; i++){ scanf("%d", &a[i]); sum += a[i]; } n++; for(int i = 1;i <= sum; i++){ a[n - 1] = i; sum += i; bool f = true; for(int q = 0;q < n; q++){ vector<bool > dp(N,false); dp[0] = true; for(int j = 0;j < n; j++){ if(j == q){ continue; } for(int k = sum - a[j];k >= 0; k--){ if(dp[k]){ dp[k + a[j]] = true; } } } if(!dp[(sum - a[q]) / 2] || (sum - a[q]) % 2 == 1){ f = false; break; } } sum -= i; if(f){ s.insert(i); } } cout << s.size() << endl; for(auto to : s){ cout << to << " "; } }

Compilation message (stderr)

bootfall.cpp:18:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main()
      ^
bootfall.cpp: In function 'int main()':
bootfall.cpp:21:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
  ~~~~~^~~~~~~~~~
bootfall.cpp:23:8: 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...