Submission #1028265

# Submission time Handle Problem Language Result Execution time Memory
1028265 2024-07-19T15:40:54 Z vjudge1 Ice Hockey World Championship (CEOI15_bobek) C++17
100 / 100
192 ms 20932 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
vector<int> df(vector<int> v) {
    int n = v.size();
    vector<int> res;
    for(int mask = 0; mask < (1 << n); mask++) {
        int sum = 0;
        for(int i = 0; i < n; i++) {
            sum += ((mask >> 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;
    a.resize(a1);
    vector<int> b = v;
    reverse(b.begin(), b.end());
    b.resize(b1);
    reverse(b.begin(), b.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";
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
}

Compilation message

bobek.cpp: In function 'void solve()':
bobek.cpp:47:19: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |         while(idx < y.size() && cur + y[idx] > m) {
      |               ~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 448 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 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 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 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
# Verdict Execution time Memory Grader output
1 Correct 16 ms 2020 KB Output is correct
2 Correct 46 ms 5588 KB Output is correct
3 Correct 192 ms 20916 KB Output is correct
4 Correct 44 ms 5460 KB Output is correct
5 Correct 7 ms 1756 KB Output is correct
6 Correct 5 ms 992 KB Output is correct
7 Correct 12 ms 1632 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 22 ms 2912 KB Output is correct
2 Correct 16 ms 2144 KB Output is correct
3 Correct 71 ms 10504 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 3 ms 992 KB Output is correct
6 Correct 10 ms 1496 KB Output is correct
7 Correct 10 ms 1620 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 31 ms 3676 KB Output is correct
2 Correct 69 ms 6736 KB Output is correct
3 Correct 75 ms 6732 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 37 ms 6748 KB Output is correct
6 Correct 165 ms 20932 KB Output is correct
7 Correct 78 ms 6728 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 150 ms 12656 KB Output is correct
2 Correct 17 ms 2144 KB Output is correct
3 Correct 6 ms 1116 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 3 ms 1116 KB Output is correct
6 Correct 139 ms 12872 KB Output is correct
7 Correct 10 ms 1752 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 15 ms 1888 KB Output is correct
2 Correct 42 ms 5456 KB Output is correct
3 Correct 5 ms 1112 KB Output is correct
4 Correct 5 ms 992 KB Output is correct
5 Correct 39 ms 6576 KB Output is correct
6 Correct 14 ms 2144 KB Output is correct
7 Correct 181 ms 20832 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 189 ms 20912 KB Output is correct
2 Correct 15 ms 2140 KB Output is correct
3 Correct 5 ms 992 KB Output is correct
4 Correct 191 ms 20812 KB Output is correct
5 Correct 49 ms 10704 KB Output is correct
6 Correct 10 ms 1496 KB Output is correct
7 Correct 21 ms 2908 KB Output is correct