답안 #967718

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
967718 2024-04-22T16:59:19 Z vjudge1 Ice Hockey World Championship (CEOI15_bobek) C++17
100 / 100
314 ms 34364 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 17608 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 17652 KB Output is correct
2 Correct 4 ms 17500 KB Output is correct
3 Correct 4 ms 17676 KB Output is correct
4 Correct 4 ms 17500 KB Output is correct
5 Correct 4 ms 17496 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 17496 KB Output is correct
2 Correct 4 ms 17688 KB Output is correct
3 Correct 4 ms 17500 KB Output is correct
4 Correct 4 ms 17500 KB Output is correct
5 Correct 4 ms 17752 KB Output is correct
6 Correct 5 ms 17496 KB Output is correct
7 Correct 4 ms 17500 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 17496 KB Output is correct
2 Correct 4 ms 17496 KB Output is correct
3 Correct 4 ms 17500 KB Output is correct
4 Correct 4 ms 17500 KB Output is correct
5 Correct 5 ms 17696 KB Output is correct
6 Correct 4 ms 17496 KB Output is correct
7 Correct 4 ms 17500 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 23 ms 19408 KB Output is correct
2 Correct 69 ms 21992 KB Output is correct
3 Correct 307 ms 34292 KB Output is correct
4 Correct 65 ms 21952 KB Output is correct
5 Correct 10 ms 18896 KB Output is correct
6 Correct 7 ms 18432 KB Output is correct
7 Correct 4 ms 17500 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 31 ms 19908 KB Output is correct
2 Correct 27 ms 19404 KB Output is correct
3 Correct 142 ms 26984 KB Output is correct
4 Correct 4 ms 17496 KB Output is correct
5 Correct 7 ms 18392 KB Output is correct
6 Correct 11 ms 18896 KB Output is correct
7 Correct 4 ms 17500 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 46 ms 20936 KB Output is correct
2 Correct 91 ms 25536 KB Output is correct
3 Correct 96 ms 25788 KB Output is correct
4 Correct 4 ms 17500 KB Output is correct
5 Correct 41 ms 25444 KB Output is correct
6 Correct 130 ms 34112 KB Output is correct
7 Correct 4 ms 17496 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 202 ms 31664 KB Output is correct
2 Correct 22 ms 19404 KB Output is correct
3 Correct 10 ms 18308 KB Output is correct
4 Correct 4 ms 17500 KB Output is correct
5 Correct 8 ms 18392 KB Output is correct
6 Correct 125 ms 31260 KB Output is correct
7 Correct 4 ms 17924 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 19408 KB Output is correct
2 Correct 68 ms 21992 KB Output is correct
3 Correct 9 ms 18388 KB Output is correct
4 Correct 9 ms 18392 KB Output is correct
5 Correct 46 ms 24936 KB Output is correct
6 Correct 17 ms 19408 KB Output is correct
7 Correct 3 ms 17500 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 243 ms 34364 KB Output is correct
2 Correct 23 ms 19408 KB Output is correct
3 Correct 10 ms 18304 KB Output is correct
4 Correct 314 ms 34296 KB Output is correct
5 Correct 57 ms 27056 KB Output is correct
6 Correct 11 ms 18896 KB Output is correct
7 Correct 4 ms 17500 KB Output is correct