# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
864144 | 2023-10-22T07:26:53 Z | wii | Ice Hockey World Championship (CEOI15_bobek) | C++17 | 423 ms | 10700 KB |
#include <bits/stdc++.h> using namespace std; typedef double db; typedef long long ll; typedef long double ld; #define int ll typedef pair<int, int> pii; #define X first #define Y second #define gcd __gcd #define pb push_back #define all(x) (x).begin(), (x).end() #define bit(i, mask) ((mask) >> (i) & 1) #define reset(x, val) memset(x, val, sizeof(x)) #define foru(i,a,b) for(int i = (a); i <= (b); ++i) #define ford(i,a,b) for(int i = (a); i >= (b); --i) #define FastIO ios::sync_with_stdio(0), cin.tie(0), cout.tie(0); template<typename T> bool maximize(T &res, const T &val) { if (res < val) { res = val; return true; } return false; } template<typename T> bool minimize(T &res, const T &val) { if (val < res) { res = val; return true; } return false; } const ll Linf = 0x3f3f3f3f3f3f3f3f; const int Inf = 0x3f3f3f3f; const ll Mod = 1e9 + 7; const ll Mod2 = ll(1e9) + 9; const int Lim = 1e6 + 5; const int inv6 = 166666668; /// ====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*==== const int base = 3; const int N = 40 + 2; const int K = log2(N); const int dx[] = {+1, -1, 0, 0}; const int dy[] = {0, 0, +1, -1}; const int block_size = sqrt(2e9) + 2; int n, m; int a[N]; vector<int> lf; void solve() { cin >> n >> m; foru(i, 1, n) cin >> a[i]; int mid = (n >> 1) + (n & 1); for (int mask = 0; mask < (1LL << mid); ++mask) { int sum = 0; foru(i, 1, mid) if (mask >> i - 1 & 1) sum += a[i]; lf.pb(sum); } sort(all(lf)); int ans = 0; for (int mask = 0; mask < (1LL << n - mid); ++mask) { int sum = 0; foru(i, mid + 1, n) if (mask >> i - mid - 1 & 1) sum += a[i]; ans += upper_bound(all(lf), m - sum) - lf.begin(); } cout << ans; } signed main() { FastIO; #define task "test" if (fopen(task".inp", "r")) { freopen(task".inp", "r", stdin); freopen(task".out", "w", stdout); } int ntest = 1; // cin >> ntest; while (ntest--) { //cout << "Case " << q << ": " << "\n"; solve(); cout << "\n"; } return 0; } /** /\_/\ * (= ._.) * / >TL \>AC **/
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 1 ms | 348 KB | Output is correct |
6 | Correct | 1 ms | 344 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 1 ms | 348 KB | Output is correct |
6 | Correct | 1 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 25 ms | 1500 KB | Output is correct |
2 | Correct | 92 ms | 2520 KB | Output is correct |
3 | Correct | 405 ms | 9416 KB | Output is correct |
4 | Correct | 84 ms | 2520 KB | Output is correct |
5 | Correct | 14 ms | 992 KB | Output is correct |
6 | Correct | 7 ms | 736 KB | Output is correct |
7 | Correct | 13 ms | 1100 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 36 ms | 1500 KB | Output is correct |
2 | Correct | 28 ms | 1752 KB | Output is correct |
3 | Correct | 167 ms | 6356 KB | Output is correct |
4 | Correct | 1 ms | 532 KB | Output is correct |
5 | Correct | 6 ms | 736 KB | Output is correct |
6 | Correct | 13 ms | 964 KB | Output is correct |
7 | Correct | 13 ms | 988 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 57 ms | 2656 KB | Output is correct |
2 | Correct | 131 ms | 6352 KB | Output is correct |
3 | Correct | 121 ms | 5844 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 80 ms | 4564 KB | Output is correct |
6 | Correct | 231 ms | 10700 KB | Output is correct |
7 | Correct | 87 ms | 4820 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 285 ms | 9152 KB | Output is correct |
2 | Correct | 25 ms | 1496 KB | Output is correct |
3 | Correct | 8 ms | 840 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 7 ms | 840 KB | Output is correct |
6 | Correct | 185 ms | 10208 KB | Output is correct |
7 | Correct | 12 ms | 992 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 27 ms | 1496 KB | Output is correct |
2 | Correct | 78 ms | 2520 KB | Output is correct |
3 | Correct | 7 ms | 732 KB | Output is correct |
4 | Correct | 8 ms | 736 KB | Output is correct |
5 | Correct | 90 ms | 5712 KB | Output is correct |
6 | Correct | 22 ms | 1500 KB | Output is correct |
7 | Correct | 220 ms | 9412 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 340 ms | 9928 KB | Output is correct |
2 | Correct | 28 ms | 1500 KB | Output is correct |
3 | Correct | 8 ms | 736 KB | Output is correct |
4 | Correct | 423 ms | 10336 KB | Output is correct |
5 | Correct | 120 ms | 4748 KB | Output is correct |
6 | Correct | 12 ms | 992 KB | Output is correct |
7 | Correct | 25 ms | 1496 KB | Output is correct |