Submission #920849

# Submission time Handle Problem Language Result Execution time Memory
920849 2024-02-03T06:19:35 Z dwuy Ice Hockey World Championship (CEOI15_bobek) C++14
20 / 100
69 ms 8420 KB
#include <bits/stdc++.h>

#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL)
#define file(a) freopen(a".inp","r",stdin); freopen(a".out", "w",stdout)
#define fi first
#define se second
#define endl "\n"
#define len(s) int32_t(s.length())
#define MASK(k)(1LL<<(k))
#define TASK ""

using namespace std;

typedef tuple<int, int, int> tpiii;
typedef pair<double, double> pdd;
typedef pair<int, int> pii;
typedef long long ll;

const long long OO = 1e18;
const int MOD = 1e9 + 7;
const int INF = 1e9;
const int MX = 41;

int n, m;
int a[MX];
int f1[MASK(20) + 5];
int f2[MASK(20) + 5];

void nhap(){
    cin >> n >> m;
    for(int i=1; i<=n; i++) cin >> a[i];
}

void solve(){
    int mid = n>>1;
    int id1, id2; id1 = id2 = 0;
    
    for(int mask=0; mask<MASK(mid); mask++){
        id1++;
        for(int f=mask; f; f-=-f&f){
            int i = __lg(-f&f) + 1;
            f1[id1] += a[i];
        }
    }       

    for(int mask=0; mask<MASK(n - mid); mask++){
        id2++;
        for(int f=mask; f; f-=-f&f){
            int i = __lg(-f&f) + mid + 1;
            f2[id2] += a[i];
        }
    }

    sort(f1+1, f1+id1+1);
    sort(f2+1, f2+id2+1);

    int ans = 0;

    for(int i=1; i<=id1; i++){
        while(id2 >= 1 && f1[i] + f2[id2] > m) id2--;
        ans += f1[i] + f2[id2] <= m? id2 : 0;
    }

    cout << ans;
}

int32_t main(){
    fastIO;
    // file(TASK);

    nhap();
    solve();

    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 600 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 348 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 1 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 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 17 ms 1116 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 20 ms 1372 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 33 ms 1884 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 51 ms 6488 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 1368 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 69 ms 8420 KB Output isn't correct
2 Halted 0 ms 0 KB -