Submission #155004

#TimeUsernameProblemLanguageResultExecution timeMemory
155004TadijaSebezIce Hockey World Championship (CEOI15_bobek)C++11
100 / 100
442 ms16892 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back const int N=43; ll a[N],K; int n; vector<ll> Build(int l, int r) { int sz=r-l+1; vector<ll> ans; ans.reserve(1<<sz); for(int mask=0;mask<1<<sz;mask++) { ll sum=0; for(int i=0;i<sz;i++) if(mask>>i&1) sum+=a[l+i]; ans.pb(sum); } sort(ans.begin(),ans.end()); return ans; } int main() { scanf("%i %lld",&n,&K); for(int i=1;i<=n;i++) scanf("%lld",&a[i]); int m=n/2; vector<ll> L,R; L=Build(1,m); R=Build(m+1,n); ll ans=0; for(int i=0;i<L.size();i++) { int j=upper_bound(R.begin(),R.end(),K-L[i])-R.begin(); ans+=j; } printf("%lld\n",ans); return 0; }

Compilation message (stderr)

bobek.cpp: In function 'int main()':
bobek.cpp:31:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<L.size();i++)
              ~^~~~~~~~~
bobek.cpp:24:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%i %lld",&n,&K);
  ~~~~~^~~~~~~~~~~~~~~~~
bobek.cpp:25:29: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i=1;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...