Submission #170314

#TimeUsernameProblemLanguageResultExecution timeMemory
170314ngmhIce Hockey World Championship (CEOI15_bobek)C++11
100 / 100
570 ms8696 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define FOR(i, a, b) for(ll i = a; i < b; i++) ll n, m, o, t, sum, ans, a[50], s[1050000]; bitset<50> c; int main(){ cin >> n >> m; o = n/2; t = n-o; FOR(i, 0, n) cin >> a[i]; FOR(i, 0, (1 << o)){ c = bitset<50>(i); FOR(j, 0, o){ if(c.test(j)) s[i] += a[j]; } } sort(s, s+(1 << o)); FOR(i, 0, (1 << t)){ c = bitset<50>(i); sum = 0; FOR(j, 0, t){ if(c.test(j)) sum += a[o+j]; } ans += upper_bound(s, s+(1<<o), m-sum)-s; } cout << ans; }
#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...