답안 #1005090

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1005090 2024-06-22T07:06:28 Z milisav Ice Hockey World Championship (CEOI15_bobek) C++14
100 / 100
315 ms 16872 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;
                A[j].push_back(C[__builtin_ctzll (msk) + shift]);
                cur = cur & (cur - 1);
                while (cur) {
                    A[j].back() += (C[__builtin_ctzll(cur)  + shift]);
                    cur = cur & (cur - 1);
                }
            }
        }


        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:45:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |         for (int i = 0; i < A[0].size(); i++) {
      |                         ~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 344 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 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 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 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 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 16 ms 1884 KB Output is correct
2 Correct 66 ms 4896 KB Output is correct
3 Correct 315 ms 16724 KB Output is correct
4 Correct 59 ms 7516 KB Output is correct
5 Correct 5 ms 4444 KB Output is correct
6 Correct 3 ms 860 KB Output is correct
7 Correct 5 ms 4700 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 23 ms 2396 KB Output is correct
2 Correct 19 ms 5208 KB Output is correct
3 Correct 114 ms 8792 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 2 ms 860 KB Output is correct
6 Correct 6 ms 1372 KB Output is correct
7 Correct 5 ms 1496 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 35 ms 4444 KB Output is correct
2 Correct 87 ms 9820 KB Output is correct
3 Correct 84 ms 8792 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 31 ms 7932 KB Output is correct
6 Correct 96 ms 16872 KB Output is correct
7 Correct 43 ms 7768 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 181 ms 14164 KB Output is correct
2 Correct 15 ms 1880 KB Output is correct
3 Correct 5 ms 860 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 2 ms 992 KB Output is correct
6 Correct 96 ms 14312 KB Output is correct
7 Correct 5 ms 4956 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 18 ms 5468 KB Output is correct
2 Correct 56 ms 4696 KB Output is correct
3 Correct 5 ms 860 KB Output is correct
4 Correct 5 ms 860 KB Output is correct
5 Correct 35 ms 7044 KB Output is correct
6 Correct 10 ms 4956 KB Output is correct
7 Correct 91 ms 16864 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 193 ms 16860 KB Output is correct
2 Correct 17 ms 1884 KB Output is correct
3 Correct 5 ms 860 KB Output is correct
4 Correct 284 ms 16872 KB Output is correct
5 Correct 43 ms 9528 KB Output is correct
6 Correct 6 ms 1368 KB Output is correct
7 Correct 10 ms 2528 KB Output is correct