답안 #1005083

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1005083 2024-06-22T07:00:59 Z milisav Ice Hockey World Championship (CEOI15_bobek) C++14
100 / 100
401 ms 16864 KB
    #include<bits/stdc++.h>
    using namespace std;
    #define ll long long
    #define endl '\n'
    #define FF first
    #define SS second
    #define all(a) a.begin(), a.end()
    #define mod (ll)(1000000007)

    int main() {
        ios_base::sync_with_stdio(0);cin.tie(0);

        int n;
        ll m;
        cin >> n >> m;

        vector<ll> C(n);
        for (int i = 0; i < n; i++) {
            cin >> C[i];
        }

        array<int, 2> sz = {n / 2, (n + 1) / 2};
        vector<vector<ll>> A(2);
        A[0].clear(), A[1].clear();
        A[0].reserve(1 << 20), A[1].reserve(1 << 20);

        for (int j = 0; j < 2; j++) {
            int shift = (j ? sz[j - 1] : 0);
            for (int msk = 1; msk < (1 << sz[j]); msk++) {
                int cur = msk;
                ll sum=0;
                for(int k=0;k<sz[j];k++) {
                    if(msk&(1<<k)) sum+=C[k+shift];
                }
                A[j].push_back(sum);
            }
        }


        ll ans = 0;

        sort(all(A[1]));
        A[0].push_back(0);
        for (int i = 0; i < A[0].size(); i++) {
            if (A[0][i] > m) {
                continue;
            }
            ans++;
            int ind = upper_bound(all(A[1]), m - A[0][i]) - A[1].begin();
            ans += ind;

        }
        cout << ans;
    }

Compilation message

bobek.cpp: In function 'int main()':
bobek.cpp:30:21: warning: unused variable 'cur' [-Wunused-variable]
   30 |                 int cur = msk;
      |                     ^~~
bobek.cpp:44:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |         for (int i = 0; i < A[0].size(); i++) {
      |                         ~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 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 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 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 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 1 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 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 25 ms 1884 KB Output is correct
2 Correct 88 ms 5980 KB Output is correct
3 Correct 401 ms 16724 KB Output is correct
4 Correct 88 ms 4444 KB Output is correct
5 Correct 10 ms 1372 KB Output is correct
6 Correct 6 ms 996 KB Output is correct
7 Correct 11 ms 4668 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 36 ms 2496 KB Output is correct
2 Correct 28 ms 3604 KB Output is correct
3 Correct 166 ms 9732 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 5 ms 4956 KB Output is correct
6 Correct 12 ms 1372 KB Output is correct
7 Correct 11 ms 1372 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 55 ms 4444 KB Output is correct
2 Correct 129 ms 7704 KB Output is correct
3 Correct 122 ms 9552 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 71 ms 6752 KB Output is correct
6 Correct 191 ms 16724 KB Output is correct
7 Correct 78 ms 8528 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 263 ms 13648 KB Output is correct
2 Correct 24 ms 1884 KB Output is correct
3 Correct 9 ms 4956 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 6 ms 860 KB Output is correct
6 Correct 176 ms 13652 KB Output is correct
7 Correct 11 ms 1500 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 1880 KB Output is correct
2 Correct 80 ms 6912 KB Output is correct
3 Correct 8 ms 856 KB Output is correct
4 Correct 8 ms 4700 KB Output is correct
5 Correct 76 ms 6740 KB Output is correct
6 Correct 19 ms 1880 KB Output is correct
7 Correct 185 ms 16720 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 298 ms 16864 KB Output is correct
2 Correct 30 ms 4956 KB Output is correct
3 Correct 8 ms 4696 KB Output is correct
4 Correct 384 ms 16816 KB Output is correct
5 Correct 90 ms 10844 KB Output is correct
6 Correct 11 ms 1372 KB Output is correct
7 Correct 21 ms 6124 KB Output is correct