Submission #1121490

#TimeUsernameProblemLanguageResultExecution timeMemory
1121490vjudge1Ice Hockey World Championship (CEOI15_bobek)C++17
100 / 100
449 ms20912 KiB
// Ali // #pragma GCC optimize("Ofast,unroll-loops") #include <bits/stdc++.h> using namespace std; #define int long long int #define ins insert #define pii pair<int,int> #define pb push_back #define endl '\n' #define putr(x) cout<<x<<endl;return; #define all(x) x.begin(),x.end() const int mod = 1e9 +7, sze = 3e5+23, inf = 2e9, LG = 19,pr = 31; void fast(){ int n,k; cin>>n>>k; vector<int> arr(n); for(int i=0;i<n;i++){ cin>>arr[i]; } int ans=0; vector<int> a,b; for(int i=0;i<n/2;i++){ a.pb(arr[i]); } for(int j=n/2;j<n;j++){ b.pb(arr[j]); } vector<int> al,bl; for(int mask =0;mask<(1<< (a.size() ));mask++){ int sum=0; for(int i =0;i<30;i++){ if(mask & (1<<i)){ sum+=a[i]; } } al.pb(sum); } for(int mask =0;mask<(1<< (b.size() ));mask++){ int sum=0; for(int i =0;i<30;i++){ if(mask & (1<<i)){ sum+=b[i]; } } bl.pb(sum); } // sort(all(al)); sort(all(bl)); for(auto v:al){ int lazim = k - v; ans+= upper_bound(all(bl),lazim) - bl.begin(); } putr(ans); } signed main(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int tt = 1; // cin>>tt; while(tt--){ fast(); } return 0; }
#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...