Submission #781197

#TimeUsernameProblemLanguageResultExecution timeMemory
781197NK_Ice Hockey World Championship (CEOI15_bobek)C++17
40 / 100
178 ms20828 KiB
// Success consists of going from failure to failure without loss of enthusiasm #include <bits/stdc++.h> using namespace std; #define nl '\n' #define sz(x) int(x.size()) using ll = long long; template<class T> using V = vector<T>; int main() { cin.tie(0)->sync_with_stdio(0); // LITERALLY JUST MITM int N; ll M; cin >> N >> M; int a = min(20, N), b = N - a; V<ll> A(a), B(b); for(auto& x : A) cin >> x; for(auto& x : B) cin >> x; V<ll> SA, SB; auto get = [&](const V<ll>& X) { int n = sz(X); V<ll> S; for(int i = 0; i < (1<<n); i++) { ll sum = 0; for(int b = 0; b < n; b++) if ((i >> b) & 1) sum += X[b]; if (sum <= M) S.push_back(sum); } return S; }; SA = get(A); SB = get(B); ll ans = 0; for(auto x : SA) { ll left = M - x; int amt = upper_bound(begin(SB), end(SB), left) - begin(SB); ans += amt; } cout << ans << nl; 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...