Submission #344749

#TimeUsernameProblemLanguageResultExecution timeMemory
344749fixikmilaBootfall (IZhO17_bootfall)C++14
100 / 100
422 ms5992 KiB
#include <bits/stdc++.h> using namespace std; #define MOD 1000000007 typedef long long ll; typedef pair<ll,ll>pll; typedef long double ld; ll bin_pow(ll a,ll b){ if(b==0)return 1; if(b%2==0){ ll t=bin_pow(a,b/2); return t*t%MOD; } else return a*bin_pow(a,b-1)%MOD; } ll dp[250001],d[250001]; int main() { //freopen("stones.in","r",stdin); //freopen("stones.out","w",stdout); ios::sync_with_stdio(false); cin.tie(0); ll t=1,n,m,k=0,sum=0,l=0,r=0,x=0,y=0,z=0,ans=0,mn=LLONG_MAX,mx=LLONG_MIN; cin>>n; vector<ll>a(n); dp[0]=1; for(int i=0;i<n;i++){ cin>>a[i]; sum+=a[i]; for(int j=sum;j>=a[i];j--)dp[j]+=dp[j-a[i]];// с конца т к к более мелким еще не успели прибавить } if(sum%2||!dp[sum/2]){ cout<<0; return 0; } for(int i=0;i<n;i++){ for(int j=a[i];j<=sum;j++)dp[j]-=dp[j-a[i]];//сначала, тк чтобы когда мы отнимали от j-того, от j-a[i]-го уже было отнято то, что было сделано с помощью а_и sum-=a[i]; for(int j=0;j<=500*500;j++){ if((sum+j)%2||!dp[(sum+j)/2])d[j]=1; } sum+=a[i]; for(int j=sum;j>=a[i];j--)dp[j]+=dp[j-a[i]]; } vector<ll>c; for(int i=0;i<=250000;i++){ if(d[i])continue; c.push_back(i); } cout<<c.size()<<"\n"; for(auto u : c)cout<<u<<" "; return 0; }

Compilation message (stderr)

bootfall.cpp: In function 'int main()':
bootfall.cpp:22:8: warning: unused variable 't' [-Wunused-variable]
   22 |     ll t=1,n,m,k=0,sum=0,l=0,r=0,x=0,y=0,z=0,ans=0,mn=LLONG_MAX,mx=LLONG_MIN;
      |        ^
bootfall.cpp:22:14: warning: unused variable 'm' [-Wunused-variable]
   22 |     ll t=1,n,m,k=0,sum=0,l=0,r=0,x=0,y=0,z=0,ans=0,mn=LLONG_MAX,mx=LLONG_MIN;
      |              ^
bootfall.cpp:22:16: warning: unused variable 'k' [-Wunused-variable]
   22 |     ll t=1,n,m,k=0,sum=0,l=0,r=0,x=0,y=0,z=0,ans=0,mn=LLONG_MAX,mx=LLONG_MIN;
      |                ^
bootfall.cpp:22:26: warning: unused variable 'l' [-Wunused-variable]
   22 |     ll t=1,n,m,k=0,sum=0,l=0,r=0,x=0,y=0,z=0,ans=0,mn=LLONG_MAX,mx=LLONG_MIN;
      |                          ^
bootfall.cpp:22:30: warning: unused variable 'r' [-Wunused-variable]
   22 |     ll t=1,n,m,k=0,sum=0,l=0,r=0,x=0,y=0,z=0,ans=0,mn=LLONG_MAX,mx=LLONG_MIN;
      |                              ^
bootfall.cpp:22:34: warning: unused variable 'x' [-Wunused-variable]
   22 |     ll t=1,n,m,k=0,sum=0,l=0,r=0,x=0,y=0,z=0,ans=0,mn=LLONG_MAX,mx=LLONG_MIN;
      |                                  ^
bootfall.cpp:22:38: warning: unused variable 'y' [-Wunused-variable]
   22 |     ll t=1,n,m,k=0,sum=0,l=0,r=0,x=0,y=0,z=0,ans=0,mn=LLONG_MAX,mx=LLONG_MIN;
      |                                      ^
bootfall.cpp:22:42: warning: unused variable 'z' [-Wunused-variable]
   22 |     ll t=1,n,m,k=0,sum=0,l=0,r=0,x=0,y=0,z=0,ans=0,mn=LLONG_MAX,mx=LLONG_MIN;
      |                                          ^
bootfall.cpp:22:46: warning: unused variable 'ans' [-Wunused-variable]
   22 |     ll t=1,n,m,k=0,sum=0,l=0,r=0,x=0,y=0,z=0,ans=0,mn=LLONG_MAX,mx=LLONG_MIN;
      |                                              ^~~
bootfall.cpp:22:52: warning: unused variable 'mn' [-Wunused-variable]
   22 |     ll t=1,n,m,k=0,sum=0,l=0,r=0,x=0,y=0,z=0,ans=0,mn=LLONG_MAX,mx=LLONG_MIN;
      |                                                    ^~
bootfall.cpp:22:65: warning: unused variable 'mx' [-Wunused-variable]
   22 |     ll t=1,n,m,k=0,sum=0,l=0,r=0,x=0,y=0,z=0,ans=0,mn=LLONG_MAX,mx=LLONG_MIN;
      |                                                                 ^~
#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...