Submission #967714

# Submission time Handle Problem Language Result Execution time Memory
967714 2024-04-22T16:55:08 Z jadai007 Ice Hockey World Championship (CEOI15_bobek) C++14
90 / 100
298 ms 22568 KB
#include<bits/stdc++.h>
#define int long long

using namespace std;

vector<int> lefts, rights;
int arr[1000100], 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];
    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:28: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]
   28 |         while(idx < rights.size() && rights[idx] + x <= k) idx++;
      |               ~~~~^~~~~~~~~~~~~~~
# 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 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 0 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 1 ms 600 KB Output is correct
7 Correct 0 ms 376 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 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 344 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 1 ms 344 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 0 ms 344 KB Output is correct
7 Correct 0 ms 348 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 298 ms 21696 KB Output is correct
4 Correct 70 ms 5600 KB Output is correct
5 Correct 12 ms 1756 KB Output is correct
6 Correct 8 ms 1036 KB Output is correct
7 Correct 16 ms 1756 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 32 ms 2980 KB Output is correct
2 Correct 25 ms 2144 KB Output is correct
3 Correct 126 ms 12148 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 6 ms 1116 KB Output is correct
6 Correct 16 ms 1756 KB Output is correct
7 Correct 16 ms 1752 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 50 ms 3664 KB Output is correct
2 Correct 109 ms 7280 KB Output is correct
3 Correct 106 ms 8272 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 72 ms 8136 KB Output is correct
6 Correct 253 ms 21940 KB Output is correct
7 Correct 102 ms 7000 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 215 ms 13628 KB Output is correct
2 Correct 25 ms 2072 KB Output is correct
3 Correct 8 ms 1116 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 6 ms 1116 KB Output is correct
6 Correct 214 ms 14812 KB Output is correct
7 Correct 16 ms 1752 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 25 ms 2140 KB Output is correct
2 Correct 69 ms 5580 KB Output is correct
3 Correct 8 ms 1112 KB Output is correct
4 Correct 9 ms 1112 KB Output is correct
5 Correct 77 ms 7820 KB Output is correct
6 Correct 24 ms 2144 KB Output is correct
7 Correct 282 ms 22568 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 292 ms 21432 KB Output is correct
2 Correct 25 ms 2140 KB Output is correct
3 Correct 8 ms 1116 KB Output is correct
4 Correct 294 ms 22092 KB Output is correct
5 Correct 99 ms 11352 KB Output is correct
6 Correct 17 ms 1752 KB Output is correct
7 Correct 34 ms 3028 KB Output is correct