Submission #380172

#TimeUsernameProblemLanguageResultExecution timeMemory
380172vishesh312Ice Hockey World Championship (CEOI15_bobek)C++17
100 / 100
504 ms8848 KiB
#include "bits/stdc++.h" using namespace std; /* #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; using ordered_set = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>; */ #define all(x) begin(x), end(x) #define sz(x) (int)x.size() using ll = long long; const int mod = 1e9+7; void solve(int tc) { int n; ll k; cin >> n >> k; vector<ll> a(n/2), b(n-n/2); for (auto &x : a) cin >> x; for (auto &x : b) cin >> x; n = sz(a); int m = sz(b); ll ans = 0; vector<ll> res; for (int mask = 0; mask < (1<<n); ++mask) { ll x = 0; for (int i = 0; i < n; ++i) if (mask&(1<<i)) x += a[i]; if (x <= k) { res.push_back(x); } } sort(all(res)); for (int mask = 0; mask < (1<<m); ++mask) { ll x = 0; for (int j = 0; j < m; ++j) if (mask&(1<<j)) x += b[j]; ans += (upper_bound(all(res), k-x) - res.begin()); } cout << ans << '\n'; } signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int tc = 1; //cin >> tc; for (int i = 1; i <= tc; ++i) solve(i); 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...