Submission #870370

# Submission time Handle Problem Language Result Execution time Memory
870370 2023-11-07T13:44:04 Z vjudge1 Ice Hockey World Championship (CEOI15_bobek) C++17
100 / 100
428 ms 10664 KB
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main()
{
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];
    vector<int> sums;
    for (int i = 0; i < (1 << (n / 2)); i++)
    {
        int sum = 0;
        for (int j = 0; j < n / 2; j++)
            if ((1 << j) & i)
                sum += a[j];
        if (sum <= m)
            sums.push_back(sum);
    }
    sort(sums.begin(),sums.end());
    int sz = sums.size();
    int cnt = 0;

    for (int i = 0; i < (1 << (n - n / 2)); i++)
    {
        int sum = 0;
        for (int j = n/2; j < n; j++)
            if ((1 << (j-n/2)) & i)
                sum += a[j];
        int l = 0, r = sz-1;
        
        while (r-l > 1)
        {
            int mid = (r+l)/2;
            if (sums[mid] > m-sum)
                r = mid;
            else
                l = mid;
        }
        if (sums[r] <= m-sum)
            l = r;
        if (sums[l] <= m-sum)
        cnt+=l+1;
    }   
    cout << cnt << '\n';
}
# 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 0 ms 348 KB Output is correct
4 Correct 1 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 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
# 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 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
# Verdict Execution time Memory Grader output
1 Correct 28 ms 980 KB Output is correct
2 Correct 94 ms 2512 KB Output is correct
3 Correct 364 ms 9656 KB Output is correct
4 Correct 91 ms 2508 KB Output is correct
5 Correct 15 ms 984 KB Output is correct
6 Correct 8 ms 728 KB Output is correct
7 Correct 8 ms 432 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 40 ms 1492 KB Output is correct
2 Correct 30 ms 984 KB Output is correct
3 Correct 186 ms 5580 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 7 ms 728 KB Output is correct
6 Correct 16 ms 984 KB Output is correct
7 Correct 8 ms 428 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 66 ms 1488 KB Output is correct
2 Correct 161 ms 2512 KB Output is correct
3 Correct 134 ms 2508 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 115 ms 2516 KB Output is correct
6 Correct 320 ms 9688 KB Output is correct
7 Correct 48 ms 408 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 285 ms 4556 KB Output is correct
2 Correct 29 ms 980 KB Output is correct
3 Correct 8 ms 728 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 8 ms 728 KB Output is correct
6 Correct 250 ms 5092 KB Output is correct
7 Correct 8 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 30 ms 984 KB Output is correct
2 Correct 89 ms 2508 KB Output is correct
3 Correct 8 ms 728 KB Output is correct
4 Correct 8 ms 808 KB Output is correct
5 Correct 127 ms 2512 KB Output is correct
6 Correct 27 ms 984 KB Output is correct
7 Correct 131 ms 404 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 388 ms 10664 KB Output is correct
2 Correct 31 ms 984 KB Output is correct
3 Correct 8 ms 728 KB Output is correct
4 Correct 428 ms 9536 KB Output is correct
5 Correct 158 ms 4812 KB Output is correct
6 Correct 16 ms 980 KB Output is correct
7 Correct 15 ms 344 KB Output is correct