답안 #858960

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
858960 2023-10-09T13:09:12 Z Tenis0206 Ice Hockey World Championship (CEOI15_bobek) C++11
100 / 100
294 ms 21940 KB
#include <bits/stdc++.h>

using namespace std;

const int nmax = 40;

int n;
long long m;
long long v[nmax + 5];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n>>m;
    for(int i=1;i<=n;i++)
    {
        cin>>v[i];
    }
    int sz_a = n / 2;
    int sz_b = n - sz_a;
    vector<long long> a,b;
    for(int mask=0;mask<(1<<sz_a);mask++)
    {
        long long sum = 0;
        for(int b=0;b<sz_a;b++)
        {
            if((mask & (1<<b))!=0)
            {
                sum += v[b + 1];
            }
        }
        a.push_back(sum);
    }
    for(int mask=0;mask<(1<<sz_b);mask++)
    {
        long long sum = 0;
        for(int b=0;b<sz_b;b++)
        {
            if((mask & (1<<b))!=0)
            {
                sum += v[sz_a + b + 1];
            }
        }
        b.push_back(sum);
    }
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    int poz = b.size() - 1;
    long long rez = 0;
    for(int i=0;i<a.size();i++)
    {
        while(poz >= 0 && a[i] + b[poz] > m)
        {
            --poz;
        }
        rez += poz + 1;
    }
    cout<<rez<<'\n';
    return 0;
}

Compilation message

bobek.cpp: In function 'int main()':
bobek.cpp:51:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |     for(int i=0;i<a.size();i++)
      |                 ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 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 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 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 1 ms 348 KB Output is correct
7 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 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 480 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 69 ms 5576 KB Output is correct
3 Correct 292 ms 20916 KB Output is correct
4 Correct 68 ms 5444 KB Output is correct
5 Correct 12 ms 1756 KB Output is correct
6 Correct 7 ms 1116 KB Output is correct
7 Correct 16 ms 1500 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 31 ms 2932 KB Output is correct
2 Correct 25 ms 2140 KB Output is correct
3 Correct 123 ms 11524 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 6 ms 1112 KB Output is correct
6 Correct 15 ms 1756 KB Output is correct
7 Correct 16 ms 1628 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 49 ms 3672 KB Output is correct
2 Correct 112 ms 8524 KB Output is correct
3 Correct 106 ms 7768 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 71 ms 7308 KB Output is correct
6 Correct 249 ms 21684 KB Output is correct
7 Correct 101 ms 7756 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 216 ms 13372 KB Output is correct
2 Correct 25 ms 2144 KB Output is correct
3 Correct 8 ms 992 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 6 ms 992 KB Output is correct
6 Correct 211 ms 14920 KB Output is correct
7 Correct 16 ms 1496 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 2140 KB Output is correct
2 Correct 70 ms 5576 KB Output is correct
3 Correct 8 ms 1116 KB Output is correct
4 Correct 8 ms 1116 KB Output is correct
5 Correct 79 ms 8720 KB Output is correct
6 Correct 24 ms 2144 KB Output is correct
7 Correct 280 ms 21772 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 284 ms 21940 KB Output is correct
2 Correct 24 ms 2140 KB Output is correct
3 Correct 8 ms 1068 KB Output is correct
4 Correct 294 ms 20860 KB Output is correct
5 Correct 98 ms 12480 KB Output is correct
6 Correct 16 ms 1756 KB Output is correct
7 Correct 32 ms 2848 KB Output is correct