Submission #1101393

#TimeUsernameProblemLanguageResultExecution timeMemory
11013930pt1mus23Ice Hockey World Championship (CEOI15_bobek)C++14
100 / 100
324 ms22964 KiB
#include <bits/stdc++.h> using namespace std; #define int long long int #define ins insert #define pb push_back #define endl '\n' #define putr(x) cout<<x<<endl;return; #define all(x) x.begin(),x.end() #define _ << " " << mt19937 rng(time(0)); const int mod = 1e9 +9, sze = 2e5 +23, inf = INT_MAX, LL = 20; void _0x0(){ int n,m; cin>>n>>m; vector<int> arr(n); for(int i=0;i<n;i++){ cin>>arr[i]; } vector<int> lst; vector<int> lst2; int ans=1; vector<int> a,b; for(int i=0;i<n/2;i++){ a.pb(arr[i]); } for(int i =n/2;i<n;i++){ b.pb(arr[i]); } // for(auto v:a) cout<<v<<" ";cout<<endl; // for(auto v:b) cout<<v<<" ";cout<<endl; for(int mask=0;mask<(1<<(a.size()));mask++){ int sum=0; for(int j=0;j<a.size();j++){ if(mask & (1<<j)){ sum+=a[j]; } } lst.pb(sum); } for(int mask=0;mask<(1<<(b.size()));mask++){ int sum=0; for(int j=0;j<b.size();j++){ if(mask & (1<<j)){ sum+=b[j]; } } lst2.pb(sum); } sort(all(lst)); sort(all(lst2)); for(auto v:lst){ auto lazim = m - v; if(lazim>=0){ ans+= ( upper_bound(all(lst2),lazim) - lst2.begin() ) ; } } cout<<ans-1<<endl; } signed main(){ ios::sync_with_stdio(0); cin.tie(0); int tt = 1; // cin>>tt; while(tt--){ _0x0(); } return 0; }

Compilation message (stderr)

bobek.cpp: In function 'void _0x0()':
bobek.cpp:40:22: 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]
   40 |         for(int j=0;j<a.size();j++){
      |                     ~^~~~~~~~~
bobek.cpp:49:22: 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]
   49 |         for(int j=0;j<b.size();j++){
      |                     ~^~~~~~~~~
#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...