Submission #404899

#TimeUsernameProblemLanguageResultExecution timeMemory
404899salehIce Hockey World Championship (CEOI15_bobek)C++17
10 / 100
12 ms16716 KiB
#include <bits/stdc++.h> #define int long long #define lowval(x) (x & (-x)) #define lowind __builtin_ctzll using namespace std; const int MAXN = 40 + 3; int n, m, c[MAXN], dp[(1 << (MAXN >> 1))], pd[(1 << (MAXN >> 1))], ans; int32_t main() { ios_base::sync_with_stdio(false); cin.tie(nullptr), cout.tie(nullptr); cin >> n >> m; for (int i = 0; i < n; i++) cin >> c[i]; for (int i = 1; i < (1 << (n >> 1)); i++) dp[i] = c[lowind(i)] + dp[i - lowval(i)]; for (int i = 1; i < (1 << (n - (n >> 1))); i++) pd[i] = c[lowind(i) + (n >> 1)] + pd[i - lowval(i)]; sort(dp, dp + (n >> 1)); sort(pd, pd + n - (n >> 1)); for (int i = 0, j = (1 << (n - (n >> 1))) - 1; i < (1 << (n >> 1)); i++) { while (~j && pd[j] + dp[i] > m) j--; ans += j + 1; } cout << ans; 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...