Submission #1122383

#TimeUsernameProblemLanguageResultExecution timeMemory
1122383LilPlutonIce Hockey World Championship (CEOI15_bobek)C++14
100 / 100
381 ms8808 KiB
 #pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define fi first
#define se second
#define vvi vector<vector<int>>
#define ld long double
#define ar array
#define pb push_back
#define vi vector<int>
#define vc vector
#define vpi vector<pair<int, int>>
#define pii pair<int, int>
#define all(c) (c).begin(), (c).end()
#define endll '\n'
#define fastio ios::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr);
#define lb(a, x) lower_bound(all(a), x) - a.begin();
#define ub(a, x) upper_bound(all(a), x) - a.begin();
template<typename T> bool umax(T &res, const T &val) { if (res < val){ res = val; return true; }; return false; }
template<typename T> bool umin(T &res, const T &val) { if (res > val){ res = val; return true; }; return false; }
mt19937 rng(time(0));
const int sz = 5e5 + 5;


void solve() {
    int n, m;
    cin >> n >> m;
    vi v1, v2;
    for(int i = 0; i < n; ++i){
        int x;
        cin >> x;
        if(i < 20){
            v1.pb(x);
        }else{
            v2.pb(x);
        }
    }
    vector<int>a;
    int res = 0;
    for(int i = 0; i < (1 << v1.size()); ++i){
        int s = 0;
        for(int j = 0; j < v1.size(); ++j){
            if((1 << j) & i){
                s += v1[j];
            }
        }
        if(s <= m){
            a.pb(s);
        }
    }
    sort(all(a));
    for(int i = 0; i < (1 << v2.size()); ++i){
        int s = 0;
        for(int j = 0; j < v2.size(); ++j){
            if((1 << j) & i){
                s += v2[j];
            }
        }
        res += upper_bound(all(a), m - s) - a.begin();
    }
    cout << res << endl;
}

signed main() {
    fastio
    int T = 1;
    while (T--) {
        solve();
    }
}

Compilation message (stderr)

bobek.cpp: In function 'void solve()':
bobek.cpp:46:26: 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]
   46 |         for(int j = 0; j < v1.size(); ++j){
      |                        ~~^~~~~~~~~~~
bobek.cpp:58:26: 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]
   58 |         for(int j = 0; j < v2.size(); ++j){
      |                        ~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...