답안 #967716

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
967716 2024-04-22T16:58:12 Z jadai007 Ice Hockey World Championship (CEOI15_bobek) C++14
90 / 100
299 ms 21976 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];
    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++;
      |               ~~~~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 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 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 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 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 1 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 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 2080 KB Output is correct
2 Correct 70 ms 5388 KB Output is correct
3 Correct 299 ms 21716 KB Output is correct
4 Correct 69 ms 5576 KB Output is correct
5 Correct 12 ms 1752 KB Output is correct
6 Correct 8 ms 1116 KB Output is correct
7 Correct 16 ms 1640 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 36 ms 3036 KB Output is correct
2 Correct 25 ms 2140 KB Output is correct
3 Correct 126 ms 11692 KB Output is correct
4 Correct 1 ms 544 KB Output is correct
5 Correct 6 ms 1112 KB Output is correct
6 Correct 16 ms 1756 KB Output is correct
7 Correct 16 ms 1756 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 50 ms 3676 KB Output is correct
2 Correct 105 ms 7244 KB Output is correct
3 Correct 104 ms 8520 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 72 ms 7992 KB Output is correct
6 Correct 255 ms 21312 KB Output is correct
7 Correct 103 ms 8524 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 215 ms 14456 KB Output is correct
2 Correct 24 ms 2140 KB Output is correct
3 Correct 8 ms 1116 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 6 ms 1048 KB Output is correct
6 Correct 212 ms 13568 KB Output is correct
7 Correct 15 ms 1752 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 2140 KB Output is correct
2 Correct 69 ms 5580 KB Output is correct
3 Correct 8 ms 1116 KB Output is correct
4 Correct 8 ms 1116 KB Output is correct
5 Correct 78 ms 8280 KB Output is correct
6 Correct 24 ms 2144 KB Output is correct
7 Correct 298 ms 21396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 286 ms 21436 KB Output is correct
2 Correct 25 ms 2340 KB Output is correct
3 Correct 8 ms 1116 KB Output is correct
4 Correct 297 ms 21976 KB Output is correct
5 Correct 101 ms 12480 KB Output is correct
6 Correct 16 ms 1752 KB Output is correct
7 Correct 35 ms 3016 KB Output is correct