답안 #225667

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
225667 2020-04-21T08:02:11 Z johutha Ice Hockey World Championship (CEOI15_bobek) C++17
100 / 100
228 ms 20840 KB
#include <iostream>
#include <vector>
#include <algorithm>

#define int int64_t

using namespace std;

struct solver
{
    int n, m;
    vector<int> vals;
    vector<int> possh1;
    vector<int> possh2;

    vector<int> gethalf(int l, int r)
    {
        vector<int> res = {0};

        for (int i = l; i < r; i++)
        {
            int cs = res.size();
            for (int j = 0; j < cs; j++)
            {
                res.push_back(res[j] + vals[i]);
            }
        }
        return res;
    }

    int solve()
    {
        possh1 = gethalf(0, n / 2);
        possh2 = gethalf(n / 2, n);

        sort(possh1.begin(), possh1.end());
        sort(possh2.begin(), possh2.end());

        int res = 0;

        int rp = possh2.size();
        for (int lp = 0; lp < (int)possh1.size(); lp++)
        {
            while (rp > 0 && possh2[rp - 1] + possh1[lp] > m) rp--;
            res += rp;
        }
        return res;
    }
};

signed main()
{
    int n, m;
    solver s;
    cin >> n >> m;
    s.n = n; s.m = m;

    s.vals.resize(n);
    for (int i = 0; i < n; i++) cin >> s.vals[i];

    cout << s.solve() << "\n";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 4 ms 256 KB Output is correct
3 Correct 4 ms 256 KB Output is correct
4 Correct 5 ms 256 KB Output is correct
5 Correct 5 ms 256 KB Output is correct
6 Correct 5 ms 256 KB Output is correct
7 Correct 5 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 4 ms 256 KB Output is correct
5 Correct 5 ms 256 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 20 ms 2040 KB Output is correct
2 Correct 55 ms 5488 KB Output is correct
3 Correct 225 ms 20840 KB Output is correct
4 Correct 55 ms 5488 KB Output is correct
5 Correct 11 ms 1560 KB Output is correct
6 Correct 9 ms 1020 KB Output is correct
7 Correct 15 ms 1656 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 2932 KB Output is correct
2 Correct 23 ms 2040 KB Output is correct
3 Correct 83 ms 10604 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 7 ms 1020 KB Output is correct
6 Correct 16 ms 1656 KB Output is correct
7 Correct 15 ms 1656 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 40 ms 3572 KB Output is correct
2 Correct 82 ms 6640 KB Output is correct
3 Correct 80 ms 6640 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 39 ms 6640 KB Output is correct
6 Correct 171 ms 20840 KB Output is correct
7 Correct 79 ms 6640 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 163 ms 12780 KB Output is correct
2 Correct 22 ms 2040 KB Output is correct
3 Correct 10 ms 1020 KB Output is correct
4 Correct 5 ms 256 KB Output is correct
5 Correct 8 ms 1020 KB Output is correct
6 Correct 159 ms 12780 KB Output is correct
7 Correct 15 ms 1656 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 22 ms 2040 KB Output is correct
2 Correct 53 ms 5488 KB Output is correct
3 Correct 10 ms 1020 KB Output is correct
4 Correct 10 ms 1020 KB Output is correct
5 Correct 44 ms 6640 KB Output is correct
6 Correct 22 ms 2024 KB Output is correct
7 Correct 215 ms 20840 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 219 ms 20840 KB Output is correct
2 Correct 22 ms 2040 KB Output is correct
3 Correct 10 ms 1020 KB Output is correct
4 Correct 228 ms 20840 KB Output is correct
5 Correct 55 ms 10604 KB Output is correct
6 Correct 15 ms 1656 KB Output is correct
7 Correct 27 ms 2932 KB Output is correct