Submission #638816

#TimeUsernameProblemLanguageResultExecution timeMemory
638816HossamHero7Ice Hockey World Championship (CEOI15_bobek)C++14
100 / 100
370 ms20952 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define endl '\n' struct custom_hash { static uint64_t splitmix64(uint64_t x) { x += 0x9e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb; return x ^ (x >> 31); } size_t operator()(uint64_t x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x + FIXED_RANDOM); } }; void solve(){ ll n,m; cin>>n>>m; vector<ll> v(n); for(auto &i:v) cin>>i; vector<ll> v1; for(int mask=0;mask<(1<<n/2);mask++){ ll sum = 0; for(int i=0;i<(n>>1);i++){ if((1<<i)&mask){ sum += v[i]; } } v1.push_back(sum); } sort(v1.begin(),v1.end()); int rem = n-(n>>1); ll ans = 0; vector<ll> v2; for(int mask=0;mask<(1<<rem);mask++){ ll sum = 0; for(int i=0;i<rem;i++){ if((1<<i)&mask){ sum += v[(n>>1)+i]; } } v2.push_back(sum); } sort(v2.begin(),v2.end()); for(auto i : v1){ int upper = upper_bound(v2.begin(),v2.end(),m-i) - v2.begin(); ans += upper; } cout<<ans<<endl; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); solve(); 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...