Submission #549333

#TimeUsernameProblemLanguageResultExecution timeMemory
549333krit3379Ice Hockey World Championship (CEOI15_bobek)C++17
100 / 100
497 ms8636 KiB
#include<bits/stdc++.h> using namespace std; #define N 1005 long long k,c,sum,ans; vector<long long> a,b,v; int main(){ int n,i,j; scanf("%d %lld",&n,&k); for(i=1;i<=n/2;i++)scanf("%lld",&c),a.push_back(c); n-=n/2; for(i=1;i<=n;i++)scanf("%lld",&c),b.push_back(c); n=a.size(); for(i=0;i<1<<n;i++){ sum=0; for(j=0;j<n;j++){ if(i&(1<<j))sum+=a[j]; } v.push_back(sum); } sort(v.begin(),v.end()); n=b.size(); for(i=0;i<1<<n;i++){ sum=0; for(j=0;j<n;j++){ if(i&(1<<j))sum+=b[j]; } ans+=upper_bound(v.begin(),v.end(),k-sum)-v.begin(); } printf("%lld",ans); return 0; }

Compilation message (stderr)

bobek.cpp: In function 'int main()':
bobek.cpp:10:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |     scanf("%d %lld",&n,&k);
      |     ~~~~~^~~~~~~~~~~~~~~~~
bobek.cpp:11:29: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |     for(i=1;i<=n/2;i++)scanf("%lld",&c),a.push_back(c);
      |                        ~~~~~^~~~~~~~~~~
bobek.cpp:13:27: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |     for(i=1;i<=n;i++)scanf("%lld",&c),b.push_back(c);
      |                      ~~~~~^~~~~~~~~~~
#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...