Submission #384168

# Submission time Handle Problem Language Result Execution time Memory
384168 2021-03-31T15:53:35 Z Sorting Ice Hockey World Championship (CEOI15_bobek) C++17
100 / 100
546 ms 8796 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
template<typename T> void check_min(T &a, const T & b){ a = (a < b) ? a : b; }
template<typename T> void check_max(T &a, const T & b){ a = (a > b) ? a : b; }
const int N = 40 + 3;

int n;
ll m, a[N];
vector<ll> v;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n >> m;
    for(int i = 0; i < n; ++i)
        cin >> a[i];
    
    int half = n / 2;
    for(int mask = 0; mask < (1 << half); ++mask){
        ll sum = 0;
        for(int i = 0; i < half; ++i)
            if(mask & (1 << i))
                sum += a[i];
        v.push_back(sum);
    }
    sort(v.begin(), v.end());

    ll ans = 0;
    for(int mask = 0; mask < (1 << (n - half)); ++mask){
        ll sum = 0;
        for(int i = half; i < n; ++i)
            if(mask & (1 << (i - half)))
                sum += a[i];
        ans += upper_bound(v.begin(), v.end(), m - sum) - v.begin();
    }
    cout << ans << "\n";
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 2 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 2 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 34 ms 1008 KB Output is correct
2 Correct 107 ms 2536 KB Output is correct
3 Correct 533 ms 8672 KB Output is correct
4 Correct 108 ms 2536 KB Output is correct
5 Correct 20 ms 1008 KB Output is correct
6 Correct 8 ms 752 KB Output is correct
7 Correct 16 ms 1008 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 46 ms 1516 KB Output is correct
2 Correct 37 ms 1008 KB Output is correct
3 Correct 213 ms 4580 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 9 ms 752 KB Output is correct
6 Correct 16 ms 1008 KB Output is correct
7 Correct 20 ms 1008 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 75 ms 1516 KB Output is correct
2 Correct 199 ms 2708 KB Output is correct
3 Correct 163 ms 2536 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 107 ms 2536 KB Output is correct
6 Correct 249 ms 8672 KB Output is correct
7 Correct 96 ms 2536 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 365 ms 4580 KB Output is correct
2 Correct 31 ms 1008 KB Output is correct
3 Correct 12 ms 752 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 10 ms 752 KB Output is correct
6 Correct 184 ms 4580 KB Output is correct
7 Correct 16 ms 1008 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 34 ms 1008 KB Output is correct
2 Correct 101 ms 2536 KB Output is correct
3 Correct 10 ms 752 KB Output is correct
4 Correct 11 ms 752 KB Output is correct
5 Correct 131 ms 2660 KB Output is correct
6 Correct 21 ms 1008 KB Output is correct
7 Correct 289 ms 8672 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 413 ms 8784 KB Output is correct
2 Correct 37 ms 1008 KB Output is correct
3 Correct 12 ms 752 KB Output is correct
4 Correct 546 ms 8796 KB Output is correct
5 Correct 155 ms 4748 KB Output is correct
6 Correct 15 ms 1008 KB Output is correct
7 Correct 33 ms 1516 KB Output is correct