Submission #671119

#TimeUsernameProblemLanguageResultExecution timeMemory
671119irmuunBootfall (IZhO17_bootfall)C++17
28 / 100
1085 ms123052 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long #define pb push_back int main(){ int n; cin>>n; int a[n+5]; int sum=0; for(int i=1;i<=n;i++){ cin>>a[i]; sum+=a[i]; } sort(a+1,a+n+1); int dp[n+5][500*n+5]; for(int i=0;i<=n;i++){ fill(dp[i],dp[i]+500*n+1,0); dp[i][0]=1; int cur=0; for(int j=1;j<=n;j++){ if(i==j){ continue; } for(int k=cur;k>=0;k--){ if(dp[i][k]==1){ dp[i][k+a[j]]=1; } } cur+=a[j]; } } vector<int>ans; for(int i=1;i<=sum;i++){ bool ok=true; for(int j=0;j<=n;j++){ if(j==0){ if(sum%2==1){ ok=false; break; } if(dp[j][sum/2]==0){ ok=false; break; } } else{ if((sum+i-a[j])%2==1){ ok=false; break; } if(dp[j][(sum+i-a[j])/2]==0){ ok=false; break; } } } if(ok==true){ ans.pb(i); } } cout<<ans.size()<<endl; for(int i=0;i<ans.size();i++){ cout<<ans[i]<<' '; } }

Compilation message (stderr)

bootfall.cpp: In function 'int main()':
bootfall.cpp:62:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   62 |     for(int i=0;i<ans.size();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...