답안 #1028219

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1028219 2024-07-19T15:21:48 Z vjudge1 Ice Hockey World Championship (CEOI15_bobek) C++17
10 / 100
61 ms 10820 KB
#include <bits/stdc++.h>
using namespace std;
vector<int> df(vector<int> v) {
    int n = v.size();
    vector<int> res;
    for(int i = 0; i < (1 << n); i++) {
        int sum = 0;
        for(int j = 0; j < n; j++) {
            sum += ((i >> j) & 1) * v[j];
        }
        res.push_back(sum);
    }
    sort(res.begin(), res.end());
    return res;
}
signed main() {
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    if(n == 1) {
        if(a[0] <= m) cout << "2" << endl;
        else cout << "1" << endl;
    }
    int a1 = n / 2;
    int b1 = n - a1;
    vector<int> h = a;
    h.resize(a1);
    vector<int> h2 = a;
    reverse(h2.begin(), h2.end());
    h2.resize(b1);
    reverse(h2.begin(), h2.end());
    vector<int> x = df(h);
    vector<int> y = df(h2);
    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 << endl;
}

Compilation message

bobek.cpp: In function 'int main()':
bobek.cpp:41:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |         while(idx < y.size() && cur + y[idx] > m) {
      |               ~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 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 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 13 ms 1200 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 19 ms 1492 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 31 ms 1992 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 49 ms 7744 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 1116 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 61 ms 10820 KB Output isn't correct
2 Halted 0 ms 0 KB -