Submission #894619

# Submission time Handle Problem Language Result Execution time Memory
894619 2023-12-28T14:32:07 Z IWKR Ice Hockey World Championship (CEOI15_bobek) C++17
100 / 100
425 ms 22716 KB
#include <bits/stdc++.h>
using namespace std;

#define int long long

int32_t main() {
    int n, m;
    cin >> n >> m;
    int arr[n];
    for (int i = 0; i < n; i++) {
        cin >> arr[i];
    }
    int a = n / 2;
    vector<int> v;
    vector<int> v2;
    int ans = 0;
    for (int i = 0; i < (1 << a); i++) {
        int res = 0;
        for (int j = 0; j < a; j++) {
            if (i & (1 << j)) {
                res += arr[j];
            }
        }
        if (res <= m) {
            v.push_back(res);
        }
    }
    int b = n - a;
    for (int i = 0; i < (1 << b); i++) {
        int res = 0;
        for (int j = 0; j < b; j++) {
            if (i & (1 << j)) {
                res += arr[a + j];
            }
        }
        if (res <= m) {
            v2.push_back(res);
        }
    }
    sort(v.begin(), v.end());
    for (int i = 0; i < v2.size(); i++) {
        int low = 0;
        int high = v.size();
        while (high - low > 1) {
            int mid = (high + low) / 2;
            if (v[mid] + v2[i] <= m) {
                low = mid;
            } else {
                high = mid;
            }
        }
        ans += low + 1;
    }
    cout << ans;
}

Compilation message

bobek.cpp: In function 'int32_t main()':
bobek.cpp:41:23: 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]
   41 |     for (int i = 0; i < v2.size(); i++) {
      |                     ~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 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 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 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 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 1 ms 404 KB Output is correct
7 Correct 0 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 344 KB Output is correct
4 Correct 1 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
# Verdict Execution time Memory Grader output
1 Correct 26 ms 2056 KB Output is correct
2 Correct 87 ms 5312 KB Output is correct
3 Correct 369 ms 22192 KB Output is correct
4 Correct 84 ms 5580 KB Output is correct
5 Correct 14 ms 1580 KB Output is correct
6 Correct 8 ms 1180 KB Output is correct
7 Correct 8 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 37 ms 2764 KB Output is correct
2 Correct 30 ms 2148 KB Output is correct
3 Correct 181 ms 11700 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 7 ms 984 KB Output is correct
6 Correct 16 ms 1604 KB Output is correct
7 Correct 9 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 59 ms 3496 KB Output is correct
2 Correct 148 ms 7444 KB Output is correct
3 Correct 124 ms 8388 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 108 ms 6584 KB Output is correct
6 Correct 306 ms 21520 KB Output is correct
7 Correct 47 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 274 ms 14532 KB Output is correct
2 Correct 25 ms 1880 KB Output is correct
3 Correct 9 ms 984 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 8 ms 984 KB Output is correct
6 Correct 242 ms 13620 KB Output is correct
7 Correct 8 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 26 ms 1880 KB Output is correct
2 Correct 87 ms 5568 KB Output is correct
3 Correct 8 ms 984 KB Output is correct
4 Correct 8 ms 1088 KB Output is correct
5 Correct 118 ms 7240 KB Output is correct
6 Correct 23 ms 1880 KB Output is correct
7 Correct 130 ms 412 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 372 ms 22716 KB Output is correct
2 Correct 26 ms 2056 KB Output is correct
3 Correct 8 ms 984 KB Output is correct
4 Correct 425 ms 21864 KB Output is correct
5 Correct 159 ms 11704 KB Output is correct
6 Correct 16 ms 1488 KB Output is correct
7 Correct 15 ms 432 KB Output is correct