Submission #494600

#TimeUsernameProblemLanguageResultExecution timeMemory
494600reniBootfall (IZhO17_bootfall)C++14
100 / 100
454 ms3160 KiB
#include<iostream> #define endl '\n' using namespace std; long long a[10000000]={1}, b[10000]; bool used[1000000]; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long m,s,n,i,j, last=0, br=300000; cin>>n; for(i=0;i<n;i++) { cin>>b[i]; for(j=last;j>=0;j--) { if(a[j]) a[j+b[i]]+=a[j]; last=max(last,j+b[i]); } } if(last%2 || !a[last/2]){cout<<0<<endl;return 0;} for(i=0;i<n;i++) { last-=b[i]; for(j=0;j<=last;j++) { if(a[j])a[j+b[i]]-=a[j]; } for(j=1;j<=300000;j++) { if(a[(j+last)/2]==0 || (j+last)%2==1) { if(!used[j])br--;used[j]=1; } } for(j=last;j>=0;j--) { if(a[j]) a[j+b[i]]+=a[j]; } last+=b[i]; } cout<<br<<endl; for(j=1;j<=300000;j++) { if(!used[j])cout<<j<<" "; } cout<<endl; }

Compilation message (stderr)

bootfall.cpp: In function 'int main()':
bootfall.cpp:41:17: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   41 |                 if(!used[j])br--;used[j]=1;
      |                 ^~
bootfall.cpp:41:34: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   41 |                 if(!used[j])br--;used[j]=1;
      |                                  ^~~~
bootfall.cpp:12:15: warning: unused variable 'm' [-Wunused-variable]
   12 |     long long m,s,n,i,j, last=0, br=300000;
      |               ^
bootfall.cpp:12:17: warning: unused variable 's' [-Wunused-variable]
   12 |     long long m,s,n,i,j, last=0, br=300000;
      |                 ^
#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...