Submission #72407

# Submission time Handle Problem Language Result Execution time Memory
72407 2018-08-26T07:48:55 Z someone_aa Ice Hockey World Championship (CEOI15_bobek) C++17
10 / 100
452 ms 21020 KB
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
const int maxn = 42;
vector<ll>suma, sumb;
ll arr[maxn], n, fn, sn;
ll budget;

void get_f() {
    for(int i=0;i<(1<<fn);i++) {
        ll sum = 0LL;
        for(int j=0;j<fn;j++) {
            if(i&(1<<j)) {
                sum += arr[j];
            }
        }
        suma.pb(sum);
    }
    sort(suma.begin(), suma.end());
}

void get_s() {
    for(int i=0;i<(1<<sn);i++) {
        ll sum = 0LL;
        for(int j=0;j<sn;j++) {
            if(i&(1<<j)) {
                sum += arr[j+fn];
            }
        }
        sumb.pb(sum);
    }
    sort(sumb.begin(), sumb.end());
}

void solve() {
    ll result = 0LL;
    for(int i=0;i<suma.size();i++) {
        if(suma[i] > budget) continue;
        else {
            ll curr = lower_bound(sumb.begin(), sumb.end(), budget - suma[i]) - sumb.begin();
            if(curr != sumb.size()) curr++;
            result += 1LL * (curr);
        }
    }
    cout<<result;
}

int main() {

    cin>>n>>budget;
    for(int i=0;i<n;i++) {
        cin>>arr[i];
    }
    fn = n / 2;
    sn = n - fn;
    get_f();
    get_s();
    solve();
    return 0;
}

Compilation message

bobek.cpp: In function 'void solve()':
bobek.cpp:39:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0;i<suma.size();i++) {
                 ~^~~~~~~~~~~~
bobek.cpp:43:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             if(curr != sumb.size()) curr++;
                ~~~~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 248 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 484 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 484 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 596 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 47 ms 2200 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 50 ms 3092 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 88 ms 3776 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 366 ms 12996 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 47 ms 12996 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 452 ms 21020 KB Output isn't correct
2 Halted 0 ms 0 KB -