Submission #40517

#TimeUsernameProblemLanguageResultExecution timeMemory
40517PajarajaIce Hockey World Championship (CEOI15_bobek)C++14
100 / 100
618 ms9044 KiB
#include <bits/stdc++.h> using namespace std; long long a[40],c[2000000]; long long 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("%lld",&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]=2000000000000000000LL; 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:15:24: 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:42: 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("%lld",&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...