답안 #970448

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
970448 2024-04-26T14:35:23 Z jadai007 Ice Hockey World Championship (CEOI15_bobek) C++14
100 / 100
302 ms 34420 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;
}

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 17496 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 17500 KB Output is correct
2 Correct 4 ms 17500 KB Output is correct
3 Correct 5 ms 17620 KB Output is correct
4 Correct 5 ms 17500 KB Output is correct
5 Correct 5 ms 17500 KB Output is correct
6 Correct 6 ms 17680 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 17500 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 17500 KB Output is correct
6 Correct 4 ms 17496 KB Output is correct
7 Correct 4 ms 17496 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 17496 KB Output is correct
2 Correct 4 ms 17500 KB Output is correct
3 Correct 5 ms 17500 KB Output is correct
4 Correct 4 ms 17500 KB Output is correct
5 Correct 4 ms 17620 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 24 ms 19408 KB Output is correct
2 Correct 68 ms 21988 KB Output is correct
3 Correct 302 ms 34420 KB Output is correct
4 Correct 65 ms 21984 KB Output is correct
5 Correct 11 ms 19148 KB Output is correct
6 Correct 8 ms 18392 KB Output is correct
7 Correct 4 ms 17500 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 32 ms 19912 KB Output is correct
2 Correct 24 ms 19408 KB Output is correct
3 Correct 136 ms 26320 KB Output is correct
4 Correct 3 ms 17500 KB Output is correct
5 Correct 7 ms 18392 KB Output is correct
6 Correct 12 ms 18896 KB Output is correct
7 Correct 3 ms 17496 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 46 ms 20976 KB Output is correct
2 Correct 91 ms 24172 KB Output is correct
3 Correct 95 ms 24948 KB Output is correct
4 Correct 4 ms 17500 KB Output is correct
5 Correct 43 ms 24180 KB Output is correct
6 Correct 131 ms 34312 KB Output is correct
7 Correct 4 ms 17500 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 212 ms 30196 KB Output is correct
2 Correct 23 ms 19408 KB Output is correct
3 Correct 11 ms 18308 KB Output is correct
4 Correct 4 ms 17500 KB Output is correct
5 Correct 7 ms 18392 KB Output is correct
6 Correct 122 ms 31660 KB Output is correct
7 Correct 4 ms 17500 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 23 ms 19404 KB Output is correct
2 Correct 72 ms 22040 KB Output is correct
3 Correct 9 ms 18396 KB Output is correct
4 Correct 10 ms 18316 KB Output is correct
5 Correct 46 ms 24772 KB Output is correct
6 Correct 17 ms 19412 KB Output is correct
7 Correct 4 ms 17628 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 245 ms 34308 KB Output is correct
2 Correct 23 ms 19408 KB Output is correct
3 Correct 10 ms 18308 KB Output is correct
4 Correct 292 ms 34216 KB Output is correct
5 Correct 57 ms 26296 KB Output is correct
6 Correct 11 ms 18892 KB Output is correct
7 Correct 4 ms 17500 KB Output is correct