Submission #40514

#TimeUsernameProblemLanguageResultExecution timeMemory
40514PajarajaIce Hockey World Championship (CEOI15_bobek)C++14
50 / 100
562 ms9056 KiB
#include <bits/stdc++.h> using namespace std; long long a[40],c[2000000]; int binarna(int l,int r,long long val) { if(l==r) return l; int s=(l+r)/2; if(c[s]>val) return binarna(l,s,val); return binarna(s+1,r,val); } int main() { int n; long long m,sol=0; scanf("%d%lld",&n,&m); for(int i=0;i<n;i++) scanf("%d",&a[i]); int p=n/2; for(int i=0;i<(1<<p);i++) { int ma=i; long long pr=0; for(int j=0;j<p;j++) { if(ma%2==0) pr+=a[j]; ma/=2; } c[i]=pr; } c[1<<p]=1000000000000000000LL; sort(c,c+(1<<p)+1); int q=n-p; for(int i=0;i<(1<<q);i++) { int ma=i; long long pr=0; for(int j=0;j<q;j++) { if(ma%2==0) pr+=a[p+j]; ma/=2; } sol+=binarna(0,(1<<p),m-pr); } printf("%lld",sol); }

Compilation message (stderr)

bobek.cpp: In function 'int main()':
bobek.cpp:16:39: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
  for(int i=0;i<n;i++) scanf("%d",&a[i]);
                                       ^
bobek.cpp:15:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%lld",&n,&m);
                       ^
bobek.cpp:16:40: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i=0;i<n;i++) 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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...