Submission #952159

# Submission time Handle Problem Language Result Execution time Memory
952159 2024-03-23T07:25:21 Z Bzslayed Ice Hockey World Championship (CEOI15_bobek) C++17
10 / 100
57 ms 8908 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;
}

Compilation message

bobek.cpp: In function 'int main()':
bobek.cpp:37:26: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
   37 |             if (i&(1<<j) != 0) cursum += fi[j];
      |                   ~~~~~~~^~~~
bobek.cpp:48:26: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
   48 |             if (i&(1<<j) != 0) cursum += se[j];
      |                   ~~~~~~~^~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 992 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 1496 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 1556 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 46 ms 5844 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 992 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 57 ms 8908 KB Output isn't correct
2 Halted 0 ms 0 KB -