Submission #952162

# Submission time Handle Problem Language Result Execution time Memory
952162 2024-03-23T07:42:34 Z Bzslayed Ice Hockey World Championship (CEOI15_bobek) C++17
100 / 100
330 ms 9952 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace std;
using namespace __gnu_pbds; 

#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")

#define ll long long
#define ull unsigned long long
#define ld long double
#define pll pair<ll, ll>
#define pii pair<int, int>
#define coutpair(p) cout << p.first << " " << p.second << "|"

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset;

int main(){
    ios_base::sync_with_stdio(0); 
    cin.tie(0); 
    cout.tie(0);

    ll n, m; cin >> n >> m;
    int szn = n/2, szm = n-szn;

    ll fi[szn], se[szm];
    for (int i=0; i<szn; i++) cin >> fi[i];
    for (int i=0; i<szm; i++) cin >> se[i];

    vector<ll> v;
    for (int i=0; i<(1<<szn); i++){
        ll cursum = 0;
        for (int j=0; j<szn; j++){
            if ((i&(1<<j)) != 0) cursum += fi[j];
        }
        v.push_back(cursum);
    }

    sort(v.begin(), v.end());

    ll ans = 0;
    for (int i=0; i<(1<<szm); i++){
        ll cursum = 0;
        for (int j=0; j<szm; j++){
            if ((i&(1<<j)) != 0) cursum += se[j]; 
        }

        ll ways = upper_bound(v.begin(), v.end(), m-cursum) - v.begin();
        ans += ways;
    }
    
    cout << ans;

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 504 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 1 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 456 KB Output is correct
5 Correct 1 ms 348 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 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 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 21 ms 992 KB Output is correct
2 Correct 73 ms 2516 KB Output is correct
3 Correct 320 ms 8864 KB Output is correct
4 Correct 74 ms 2520 KB Output is correct
5 Correct 8 ms 988 KB Output is correct
6 Correct 4 ms 736 KB Output is correct
7 Correct 9 ms 992 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 30 ms 1500 KB Output is correct
2 Correct 22 ms 992 KB Output is correct
3 Correct 137 ms 4856 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 5 ms 732 KB Output is correct
6 Correct 9 ms 988 KB Output is correct
7 Correct 9 ms 992 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 47 ms 1500 KB Output is correct
2 Correct 113 ms 2516 KB Output is correct
3 Correct 104 ms 2480 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 38 ms 2484 KB Output is correct
6 Correct 158 ms 9952 KB Output is correct
7 Correct 44 ms 2516 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 240 ms 4820 KB Output is correct
2 Correct 19 ms 988 KB Output is correct
3 Correct 7 ms 848 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 5 ms 736 KB Output is correct
6 Correct 99 ms 4692 KB Output is correct
7 Correct 9 ms 992 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 22 ms 992 KB Output is correct
2 Correct 67 ms 2516 KB Output is correct
3 Correct 7 ms 736 KB Output is correct
4 Correct 8 ms 736 KB Output is correct
5 Correct 43 ms 2516 KB Output is correct
6 Correct 10 ms 992 KB Output is correct
7 Correct 162 ms 9156 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 281 ms 9928 KB Output is correct
2 Correct 21 ms 1100 KB Output is correct
3 Correct 7 ms 736 KB Output is correct
4 Correct 330 ms 9420 KB Output is correct
5 Correct 75 ms 5316 KB Output is correct
6 Correct 9 ms 992 KB Output is correct
7 Correct 19 ms 1568 KB Output is correct