Submission #195605

# Submission time Handle Problem Language Result Execution time Memory
195605 2020-01-16T15:49:48 Z jovan_b Ice Hockey World Championship (CEOI15_bobek) C++17
100 / 100
384 ms 16904 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];
        }
        //cout << niz1[i+1] << " ";
    }
    //cout << endl;
    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];
        }
        //cout << niz2[i+1] << " ";
    }
    //cout << endl;
    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 3 ms 508 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 420 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 3 ms 380 KB Output is correct
4 Correct 1 ms 416 KB Output is correct
5 Correct 3 ms 380 KB Output is correct
6 Correct 2 ms 396 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 380 KB Output is correct
6 Correct 2 ms 388 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 416 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 26 ms 1936 KB Output is correct
2 Correct 88 ms 4472 KB Output is correct
3 Correct 380 ms 16692 KB Output is correct
4 Correct 89 ms 4452 KB Output is correct
5 Correct 17 ms 1372 KB Output is correct
6 Correct 11 ms 888 KB Output is correct
7 Correct 21 ms 1432 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 42 ms 2404 KB Output is correct
2 Correct 33 ms 1784 KB Output is correct
3 Correct 162 ms 8604 KB Output is correct
4 Correct 2 ms 392 KB Output is correct
5 Correct 9 ms 908 KB Output is correct
6 Correct 22 ms 1400 KB Output is correct
7 Correct 22 ms 1432 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 64 ms 3476 KB Output is correct
2 Correct 133 ms 6552 KB Output is correct
3 Correct 133 ms 6552 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 87 ms 6536 KB Output is correct
6 Correct 323 ms 16792 KB Output is correct
7 Correct 131 ms 6560 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 274 ms 12712 KB Output is correct
2 Correct 34 ms 1940 KB Output is correct
3 Correct 18 ms 1016 KB Output is correct
4 Correct 2 ms 416 KB Output is correct
5 Correct 9 ms 888 KB Output is correct
6 Correct 265 ms 12716 KB Output is correct
7 Correct 21 ms 1432 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 32 ms 1912 KB Output is correct
2 Correct 89 ms 4576 KB Output is correct
3 Correct 11 ms 880 KB Output is correct
4 Correct 12 ms 1016 KB Output is correct
5 Correct 89 ms 6576 KB Output is correct
6 Correct 37 ms 1944 KB Output is correct
7 Correct 360 ms 16904 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 367 ms 16860 KB Output is correct
2 Correct 34 ms 2004 KB Output is correct
3 Correct 12 ms 764 KB Output is correct
4 Correct 384 ms 16744 KB Output is correct
5 Correct 132 ms 8540 KB Output is correct
6 Correct 21 ms 1432 KB Output is correct
7 Correct 42 ms 2396 KB Output is correct