답안 #436340

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
436340 2021-06-24T12:47:10 Z iulia13 Ice Hockey World Championship (CEOI15_bobek) C++14
100 / 100
351 ms 16836 KB
#include <bits/stdc++.h>

using namespace std;
const int N = 2e6 + 6;
#define ll long long
map <ll, ll> cate;
map <ll, ll> dp;
set <ll> s;
ll v[N];
ll a[N], b[N];

int main()
{
    ll n, m, nr, i, h, j, na, nb;
    cin >> n >> m;
    for (i = 0; i < n; i++)
        cin >> v[i];
    h = n / 2;
    for (i = 0; i < (1 << h); i++)
    {
        for (j = 0; j < h; j++)
            if (i & (1 << j))
                a[i] += v[j];
    }
    na = (1 << h);
    sort(a, a + na);
    for (i = h; i < n; i++)
        v[i - h] = v[i];

    h = n - h;
    for (i = 0; i < (1 << h); i++)
    {
        for (j = 0; j < h; j++)
            if (i & (1 << j))
                b[i] += v[j];
    }
    nb = (1 << h);
    sort(b, b + nb);
    na--;
    nb--;
    j = nb;
    ll ans = 0;
    for (i = 0; i <= na; i++)
    {
        while (b[j] + a[i] > m && j > -1)
            j--;
        ans += (j + 1);
    }
    cout << ans;
    return 0;
}

Compilation message

bobek.cpp: In function 'int main()':
bobek.cpp:14:14: warning: unused variable 'nr' [-Wunused-variable]
   14 |     ll n, m, nr, i, h, j, na, nb;
      |              ^~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 28 ms 1740 KB Output is correct
2 Correct 81 ms 4392 KB Output is correct
3 Correct 349 ms 16820 KB Output is correct
4 Correct 81 ms 4420 KB Output is correct
5 Correct 14 ms 1356 KB Output is correct
6 Correct 9 ms 716 KB Output is correct
7 Correct 25 ms 1228 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 38 ms 2252 KB Output is correct
2 Correct 30 ms 1748 KB Output is correct
3 Correct 154 ms 8576 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 8 ms 828 KB Output is correct
6 Correct 22 ms 1344 KB Output is correct
7 Correct 20 ms 1344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 59 ms 3380 KB Output is correct
2 Correct 125 ms 6468 KB Output is correct
3 Correct 129 ms 6440 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 98 ms 6392 KB Output is correct
6 Correct 297 ms 16708 KB Output is correct
7 Correct 122 ms 6436 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 251 ms 12612 KB Output is correct
2 Correct 29 ms 1856 KB Output is correct
3 Correct 10 ms 844 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 7 ms 716 KB Output is correct
6 Correct 252 ms 12496 KB Output is correct
7 Correct 19 ms 1336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 29 ms 1844 KB Output is correct
2 Correct 82 ms 4364 KB Output is correct
3 Correct 9 ms 836 KB Output is correct
4 Correct 9 ms 716 KB Output is correct
5 Correct 89 ms 6348 KB Output is correct
6 Correct 28 ms 1868 KB Output is correct
7 Correct 332 ms 16836 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 341 ms 16708 KB Output is correct
2 Correct 30 ms 1856 KB Output is correct
3 Correct 10 ms 884 KB Output is correct
4 Correct 351 ms 16708 KB Output is correct
5 Correct 111 ms 8516 KB Output is correct
6 Correct 18 ms 1344 KB Output is correct
7 Correct 38 ms 2360 KB Output is correct