Submission #462447

# Submission time Handle Problem Language Result Execution time Memory
462447 2021-08-10T14:47:36 Z JovanB Ice Hockey World Championship (CEOI15_bobek) C++17
100 / 100
348 ms 16836 KB
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
ll niz[45];
ll niz1[5000005];
ll niz2[5000005];
 
int main(){
    ios_base::sync_with_stdio(false);
    cout.precision(10);
    cout<<fixed;
 
    int n;
    ll m;
    cin >> n >> m;
    for(int i=1; i<=n; i++){
        cin >> niz[i];
    }
    int k = n/2;
    for(int i=0; i<(1<<k); i++){
        for(int j=1; j<=k; j++){
            if(i & (1 << (j-1))) niz1[i+1] += niz[j];
        }
    }
    int p = n - k;
    for(int i=0; i<(1<<p); i++){
        for(int j=k+1; j<=n; j++){
            if(i & (1 << (j-k-1))) niz2[i+1] += niz[j];
        }
    }
    k = (1 << k);
    p = (1 << p);
    int tren = 0;
    ll cnt = 0;
    sort(niz1+1, niz1+1+k);
    sort(niz2+1, niz2+1+p);
    for(int i=k; i>=1; i--){
        while(niz1[i] + niz2[tren+1] <= m && tren < p) tren++;
        cnt += tren;
    }
    cout << cnt;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 0 ms 324 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 332 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 0 ms 280 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 316 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 276 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 320 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 27 ms 1844 KB Output is correct
2 Correct 80 ms 4300 KB Output is correct
3 Correct 347 ms 16788 KB Output is correct
4 Correct 83 ms 4432 KB Output is correct
5 Correct 14 ms 1364 KB Output is correct
6 Correct 9 ms 836 KB Output is correct
7 Correct 18 ms 1356 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 37 ms 2372 KB Output is correct
2 Correct 29 ms 1748 KB Output is correct
3 Correct 140 ms 8524 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 8 ms 856 KB Output is correct
6 Correct 18 ms 1356 KB Output is correct
7 Correct 18 ms 1364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 65 ms 3404 KB Output is correct
2 Correct 126 ms 6516 KB Output is correct
3 Correct 126 ms 6460 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 81 ms 6540 KB Output is correct
6 Correct 293 ms 16732 KB Output is correct
7 Correct 120 ms 6540 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 253 ms 12512 KB Output is correct
2 Correct 29 ms 1868 KB Output is correct
3 Correct 9 ms 836 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 7 ms 844 KB Output is correct
6 Correct 248 ms 12620 KB Output is correct
7 Correct 18 ms 1356 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 29 ms 1868 KB Output is correct
2 Correct 85 ms 4292 KB Output is correct
3 Correct 9 ms 832 KB Output is correct
4 Correct 9 ms 844 KB Output is correct
5 Correct 91 ms 6376 KB Output is correct
6 Correct 28 ms 1808 KB Output is correct
7 Correct 334 ms 16708 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 333 ms 16724 KB Output is correct
2 Correct 34 ms 1868 KB Output is correct
3 Correct 11 ms 852 KB Output is correct
4 Correct 348 ms 16836 KB Output is correct
5 Correct 113 ms 8424 KB Output is correct
6 Correct 18 ms 1356 KB Output is correct
7 Correct 37 ms 2380 KB Output is correct