답안 #1028254

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1028254 2024-07-19T15:38:00 Z lmao123456 Ice Hockey World Championship (CEOI15_bobek) C++14
20 / 100
61 ms 10584 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
vector<int> df(vector<int> v) {
    int n = v.size();
    vector<int> res;
    for (int j = 0; j < (1 << n); j++) {
        int sum = 0;
        for (int i = 0; i < n; i++) {
            sum += ((j >> i) & 1) * v[i];
        }
        res.push_back(sum);
    }
    sort(res.begin(), res.end());
    return res;
}

void solve() {
    int n, m;
    cin >> n >> m;
    vector<int> v(n);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
    if (n == 1) {
        if (v[0] <= m) {
            cout << "2" << "\n";
        } else {
            cout << "1" << "\n";
        }
        return;
    }
    int a1 = n / 2;
    int b1 = n - a1;
    vector<int> a(v.begin(), v.begin() + a1);
    vector<int> b(v.begin() + a1, v.end());
    vector<int> x = df(a);
    vector<int> y = df(b);
    reverse(y.begin(), y.end());
    int ans = 0;
    int idx = 0;
    for (int cur : x) {
        while (idx < y.size() && cur + y[idx] > m) {
            idx++;
        }
        ans += y.size() - idx;
    }
    cout << ans << "\n";
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
    return 0;
}

Compilation message

bobek.cpp: In function 'void solve()':
bobek.cpp:43:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |         while (idx < y.size() && cur + y[idx] > m) {
      |                ~~~~^~~~~~~~~~
bobek.cpp:34:9: warning: unused variable 'b1' [-Wunused-variable]
   34 |     int b1 = n - a1;
      |         ^~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 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 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 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 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 14 ms 1232 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 19 ms 1752 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 32 ms 1884 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 47 ms 6740 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 1368 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 61 ms 10584 KB Output isn't correct
2 Halted 0 ms 0 KB -