Submission #118419

# Submission time Handle Problem Language Result Execution time Memory
118419 2019-06-19T02:34:50 Z minhtung0404 Ice Hockey World Championship (CEOI15_bobek) C++17
100 / 100
213 ms 20972 KB
//https://oj.uz/problem/view/CEOI15_bobek

#include<bits/stdc++.h>
using namespace std;

vector <long long> mv[2];
int n;
long long m, ans, a[50];

void backtrack(vector <long long> & mv, int i, int n, long long sum){
    if (i == n+1){
        mv.push_back(sum);
        return;
    }
    backtrack(mv, i+1, n, sum);
    backtrack(mv, i+1, n, sum+a[i]);
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n >> m;
    for (int i = 1; i <= n; i++) cin >> a[i];
    backtrack(mv[0], 1, n/2, 0);
    backtrack(mv[1], n/2+1, n, 0);
    sort(mv[0].begin(), mv[0].end());
    sort(mv[1].begin(), mv[1].end());
    int cnt = mv[1].size()-1;
    for (auto x : mv[0]){
        while (cnt >= 0 && mv[1][cnt] + x > m) cnt--;
        ans += cnt+1;
    }
    cout << ans;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 388 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 304 KB Output is correct
7 Correct 2 ms 300 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 512 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 17 ms 2044 KB Output is correct
2 Correct 51 ms 5620 KB Output is correct
3 Correct 211 ms 20828 KB Output is correct
4 Correct 50 ms 5492 KB Output is correct
5 Correct 9 ms 1592 KB Output is correct
6 Correct 7 ms 1024 KB Output is correct
7 Correct 12 ms 1660 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 23 ms 2936 KB Output is correct
2 Correct 18 ms 2044 KB Output is correct
3 Correct 81 ms 10608 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 5 ms 1024 KB Output is correct
6 Correct 12 ms 1660 KB Output is correct
7 Correct 13 ms 1660 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 37 ms 3576 KB Output is correct
2 Correct 81 ms 6644 KB Output is correct
3 Correct 74 ms 6644 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 38 ms 6644 KB Output is correct
6 Correct 170 ms 20904 KB Output is correct
7 Correct 72 ms 6644 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 157 ms 12776 KB Output is correct
2 Correct 19 ms 2044 KB Output is correct
3 Correct 7 ms 1024 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 5 ms 1152 KB Output is correct
6 Correct 152 ms 12744 KB Output is correct
7 Correct 12 ms 1660 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 19 ms 2044 KB Output is correct
2 Correct 50 ms 5492 KB Output is correct
3 Correct 7 ms 1024 KB Output is correct
4 Correct 7 ms 1024 KB Output is correct
5 Correct 45 ms 6772 KB Output is correct
6 Correct 18 ms 2044 KB Output is correct
7 Correct 208 ms 20956 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 213 ms 20836 KB Output is correct
2 Correct 18 ms 2044 KB Output is correct
3 Correct 7 ms 1024 KB Output is correct
4 Correct 211 ms 20972 KB Output is correct
5 Correct 57 ms 10580 KB Output is correct
6 Correct 12 ms 1660 KB Output is correct
7 Correct 24 ms 3064 KB Output is correct