답안 #967717

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
967717 2024-04-22T16:59:01 Z njoop Ice Hockey World Championship (CEOI15_bobek) C++14
100 / 100
307 ms 34216 KB
#include <bits/stdc++.h>
#define ll long long
using namespace std;

ll n, m, arr[50], res1[1100010], res2[1100010], ans;
vector<ll> dp1, dp2;

void find(int idx, ll mon, int cur, int lim, ll res[]) {
    if(cur > lim) {
        res[idx] = mon;
        return;
    }
    if(mon + arr[cur] <= m) find(idx+pow(2, lim-cur), mon+arr[cur], cur+1, lim, res);
    find(idx, mon, cur+1, lim, res);
    if(cur == lim) res[idx] = mon;
}

int main() {
    cin.tie(0)->sync_with_stdio(0);
    cin >> n >> m;
    for(int i=1; i<=n; i++) {
        cin >> arr[i];
    }
    for(int i=0; i<1100010; i++) {
        res1[i] = -1;
        res2[i] = -1;
    }
    find(0, 0, 1, n/2, res1);
    find(0, 0, (n/2)+1, n, res2);
    for(int i=0; i<1100010; i++) {
        if(res1[i] != -1) dp1.push_back(res1[i]);
        if(res2[i] != -1) dp2.push_back(res2[i]);
    }
    sort(dp2.begin(), dp2.end());
    for(int i=0; i<dp1.size(); i++) {
        ans += lower_bound(dp2.begin(), dp2.end(), m-dp1[i]+1) - dp2.begin();
    }
    cout << ans;
    return 0;
}

Compilation message

bobek.cpp: In function 'int main()':
bobek.cpp:35:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |     for(int i=0; i<dp1.size(); i++) {
      |                  ~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 17752 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 17496 KB Output is correct
2 Correct 3 ms 17500 KB Output is correct
3 Correct 4 ms 17500 KB Output is correct
4 Correct 5 ms 17496 KB Output is correct
5 Correct 4 ms 17500 KB Output is correct
6 Correct 4 ms 17500 KB Output is correct
7 Correct 4 ms 17500 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 17500 KB Output is correct
2 Correct 4 ms 17676 KB Output is correct
3 Correct 6 ms 17500 KB Output is correct
4 Correct 4 ms 17496 KB Output is correct
5 Correct 4 ms 17500 KB Output is correct
6 Correct 4 ms 17500 KB Output is correct
7 Correct 4 ms 17496 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 17500 KB Output is correct
2 Correct 4 ms 17500 KB Output is correct
3 Correct 4 ms 17664 KB Output is correct
4 Correct 4 ms 17680 KB Output is correct
5 Correct 5 ms 17500 KB Output is correct
6 Correct 4 ms 17500 KB Output is correct
7 Correct 5 ms 17500 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 22 ms 19408 KB Output is correct
2 Correct 72 ms 21952 KB Output is correct
3 Correct 307 ms 34216 KB Output is correct
4 Correct 67 ms 21952 KB Output is correct
5 Correct 11 ms 18896 KB Output is correct
6 Correct 7 ms 18428 KB Output is correct
7 Correct 4 ms 17500 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 31 ms 19912 KB Output is correct
2 Correct 24 ms 19408 KB Output is correct
3 Correct 135 ms 26040 KB Output is correct
4 Correct 4 ms 17696 KB Output is correct
5 Correct 7 ms 18392 KB Output is correct
6 Correct 12 ms 18796 KB Output is correct
7 Correct 4 ms 17500 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 45 ms 20936 KB Output is correct
2 Correct 95 ms 24748 KB Output is correct
3 Correct 95 ms 24428 KB Output is correct
4 Correct 5 ms 17496 KB Output is correct
5 Correct 41 ms 23996 KB Output is correct
6 Correct 130 ms 34124 KB Output is correct
7 Correct 4 ms 17500 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 200 ms 31332 KB Output is correct
2 Correct 23 ms 19404 KB Output is correct
3 Correct 10 ms 18308 KB Output is correct
4 Correct 4 ms 17496 KB Output is correct
5 Correct 7 ms 18392 KB Output is correct
6 Correct 124 ms 31408 KB Output is correct
7 Correct 4 ms 17500 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 22 ms 19404 KB Output is correct
2 Correct 69 ms 21948 KB Output is correct
3 Correct 9 ms 18392 KB Output is correct
4 Correct 10 ms 18420 KB Output is correct
5 Correct 48 ms 24768 KB Output is correct
6 Correct 19 ms 19408 KB Output is correct
7 Correct 4 ms 17500 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 239 ms 34212 KB Output is correct
2 Correct 23 ms 19404 KB Output is correct
3 Correct 12 ms 18304 KB Output is correct
4 Correct 280 ms 34128 KB Output is correct
5 Correct 58 ms 26036 KB Output is correct
6 Correct 12 ms 18896 KB Output is correct
7 Correct 4 ms 17500 KB Output is correct