Submission #394096

#TimeUsernameProblemLanguageResultExecution timeMemory
394096TaresuIce Hockey World Championship (CEOI15_bobek)C++11
50 / 100
546 ms20768 KiB
#include <bits/stdc++.h> #define ll long long #define pb push_back #define upb(a, x) upper_bound(a.begin(), a.end(), x) #define sz size #define stvr(a) sort(a.begin(), a.end()) using namespace std; vector<ll int> l, r, rr, l1, v; ll int m; ll int n; bool lig(ll int a, ll int b){ return a&(1<<b); } int main(){ ios::sync_with_stdio(0); cin >> n >> m; for(ll int i=0;i<n;i++){ int a; cin >> a; if(a<=m) v.pb(a); } for(ll int i=0;i<v.sz()/2;i++) l.pb(v[i]); for(ll int i=v.sz()/2;i<v.sz();i++)r.pb(v[i]); for(ll int mask=0;mask<(1<<l.sz());mask++){ ll int a=0; for(ll int i=0;i<l.sz();i++){ if(lig(mask, i)) a+=l[i]; } if(a<=m) l1.pb(a); }for(ll int mask=0;mask<(1<<r.sz());mask++){ ll int a=0; for(ll int i=0;i<r.sz();i++){ if(lig(mask, i)) a+=r[i]; } if(a<=m) rr.pb(a); } stvr(rr); ll int resp=0; for(ll int i=0;i<l1.size();i++){ resp+=(ll int)(upb(rr, m-l1[i])-rr.begin()); } cout << resp << '\n'; return 0; }

Compilation message (stderr)

bobek.cpp: In function 'int main()':
bobek.cpp:26:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |  for(ll int i=0;i<v.sz()/2;i++) l.pb(v[i]);
      |                 ~^~~~~~~~~
bobek.cpp:27:25: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |  for(ll int i=v.sz()/2;i<v.sz();i++)r.pb(v[i]);
      |                        ~^~~~~~~
bobek.cpp:31:19: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |   for(ll int i=0;i<l.sz();i++){
      |                  ~^~~~~~~
bobek.cpp:37:19: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |   for(ll int i=0;i<r.sz();i++){
      |                  ~^~~~~~~
bobek.cpp:46:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |  for(ll int i=0;i<l1.size();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...