답안 #967722

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
967722 2024-04-22T17:03:51 Z jadai007 Ice Hockey World Championship (CEOI15_bobek) C++14
90 / 100
303 ms 22520 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++;
      |               ~~~~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 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 344 KB Output is correct
5 Correct 1 ms 508 KB Output is correct
6 Correct 1 ms 500 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 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 600 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 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 23 ms 2144 KB Output is correct
2 Correct 71 ms 5500 KB Output is correct
3 Correct 303 ms 21276 KB Output is correct
4 Correct 69 ms 5588 KB Output is correct
5 Correct 12 ms 1500 KB Output is correct
6 Correct 8 ms 992 KB Output is correct
7 Correct 16 ms 1756 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 32 ms 3028 KB Output is correct
2 Correct 25 ms 2140 KB Output is correct
3 Correct 121 ms 11712 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 6 ms 992 KB Output is correct
6 Correct 16 ms 2008 KB Output is correct
7 Correct 16 ms 1512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 50 ms 3676 KB Output is correct
2 Correct 105 ms 7276 KB Output is correct
3 Correct 104 ms 8268 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 75 ms 6992 KB Output is correct
6 Correct 254 ms 21428 KB Output is correct
7 Correct 104 ms 8280 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 217 ms 13120 KB Output is correct
2 Correct 24 ms 2140 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 988 KB Output is correct
6 Correct 223 ms 14404 KB Output is correct
7 Correct 16 ms 1640 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 2144 KB Output is correct
2 Correct 68 ms 5580 KB Output is correct
3 Correct 8 ms 1116 KB Output is correct
4 Correct 8 ms 988 KB Output is correct
5 Correct 77 ms 6984 KB Output is correct
6 Correct 27 ms 2140 KB Output is correct
7 Correct 281 ms 22200 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 286 ms 22196 KB Output is correct
2 Correct 25 ms 2144 KB Output is correct
3 Correct 9 ms 992 KB Output is correct
4 Correct 294 ms 22520 KB Output is correct
5 Correct 100 ms 10684 KB Output is correct
6 Correct 18 ms 1500 KB Output is correct
7 Correct 32 ms 2776 KB Output is correct