Submission #365723

#TimeUsernameProblemLanguageResultExecution timeMemory
365723kostia244Ice Hockey World Championship (CEOI15_bobek)C++17
100 / 100
503 ms8692 KiB
#pragma GCC optimize("Ofast,unroll-loops") #pragma GCC target("avx,avx2,sse,sse2") #include<bits/stdc++.h> #define all(x) begin(x), end(x) using namespace std; using ll = long long; int n; ll w, a[44]; int main() { cin.tie(0)->sync_with_stdio(0); //multitest([&](){}); cin >> n >> w; vector<ll> cn; for(int i = 0; i < n; i++) cin >> a[i]; int c = n/2; int b = n - c; for(int i = 0; i < 1<<c; i++) { ll cur = 0; for(int j = 0; j < c; j++) if((i>>j)&1) cur += a[j]; cn.push_back(cur); } ll ans = 0; sort(all(cn)); for(int i = 0; i < 1<<b; i++) { ll cur = 0; for(int j = 0; j < b; j++) if((i>>j)&1) cur += a[c+j]; ans += upper_bound(all(cn), w-cur)-cn.begin(); } cout << ans << '\n'; }
#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...