Submission #967719

# Submission time Handle Problem Language Result Execution time Memory
967719 2024-04-22T17:00:52 Z jadai007 Ice Hockey World Championship (CEOI15_bobek) C++14
90 / 100
308 ms 23080 KB
#include<bits/stdc++.h>
#define int long long

using namespace std;

vector<int> lefts, rights;
int arr[50], n, k, idx, ans;

void solve(int l, int r){
    for(int i = 0; i < (1<<(r - l + 1)); ++i){
        int sum = 0;
        for(int j = l; j <= r; ++j) if(i&(1<<(j - l))) sum += arr[j];
        if(l == 1) lefts.push_back(sum);
        else rights.push_back(sum);
    }
}

signed main(){
    cin.tie(nullptr)->sync_with_stdio(false);
    cin >> n >> k;
    for(int i = 1; i <= n; ++i) cin >> arr[i];
    if(n == 1){
        if(arr[1] <= k) cout << 1;
        else cout << 0;
        return 0;
    }
    solve(1, n / 2);
    solve(n / 2 + 1, n);
    sort(lefts.begin(), lefts.end());  sort(rights.begin(), rights.end());
    reverse(lefts.begin(), lefts.end());
    for(auto x:lefts){
        while(idx < rights.size() && rights[idx] + x <= k) idx++;
        ans+=idx;
    }
    cout << ans;
    return 0;
}

Compilation message

bobek.cpp: In function 'int main()':
bobek.cpp:32:19: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |         while(idx < rights.size() && rights[idx] + x <= k) idx++;
      |               ~~~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 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 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 23 ms 2144 KB Output is correct
2 Correct 69 ms 5588 KB Output is correct
3 Correct 308 ms 21876 KB Output is correct
4 Correct 69 ms 5828 KB Output is correct
5 Correct 13 ms 1756 KB Output is correct
6 Correct 8 ms 1112 KB Output is correct
7 Correct 16 ms 1500 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 32 ms 3032 KB Output is correct
2 Correct 29 ms 1976 KB Output is correct
3 Correct 126 ms 10744 KB Output is correct
4 Correct 0 ms 544 KB Output is correct
5 Correct 6 ms 1060 KB Output is correct
6 Correct 16 ms 1500 KB Output is correct
7 Correct 16 ms 1500 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 51 ms 3676 KB Output is correct
2 Correct 108 ms 8168 KB Output is correct
3 Correct 104 ms 8420 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 77 ms 7348 KB Output is correct
6 Correct 262 ms 23080 KB Output is correct
7 Correct 102 ms 6980 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 219 ms 14916 KB Output is correct
2 Correct 24 ms 1888 KB Output is correct
3 Correct 8 ms 1040 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 7 ms 1112 KB Output is correct
6 Correct 214 ms 13328 KB Output is correct
7 Correct 16 ms 1500 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 25 ms 2144 KB Output is correct
2 Correct 70 ms 5440 KB Output is correct
3 Correct 8 ms 988 KB Output is correct
4 Correct 8 ms 992 KB Output is correct
5 Correct 76 ms 7500 KB Output is correct
6 Correct 24 ms 2144 KB Output is correct
7 Correct 283 ms 21048 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 289 ms 21336 KB Output is correct
2 Correct 25 ms 2144 KB Output is correct
3 Correct 8 ms 1112 KB Output is correct
4 Correct 295 ms 21424 KB Output is correct
5 Correct 101 ms 10948 KB Output is correct
6 Correct 16 ms 1756 KB Output is correct
7 Correct 32 ms 3032 KB Output is correct