답안 #858958

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

using namespace std;

const int nmax = 40;

int n;
long long m;
int 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 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 600 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 344 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 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 23 ms 2144 KB Output is correct
2 Correct 71 ms 5368 KB Output is correct
3 Correct 297 ms 22252 KB Output is correct
4 Correct 68 ms 5580 KB Output is correct
5 Correct 13 ms 1752 KB Output is correct
6 Correct 8 ms 1112 KB Output is correct
7 Correct 16 ms 1500 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 32 ms 3032 KB Output is correct
2 Correct 24 ms 2144 KB Output is correct
3 Correct 120 ms 11420 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 10 ms 1116 KB Output is correct
6 Correct 16 ms 1624 KB Output is correct
7 Correct 15 ms 1500 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 52 ms 3676 KB Output is correct
2 Correct 105 ms 8024 KB Output is correct
3 Correct 103 ms 6988 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 73 ms 8492 KB Output is correct
6 Correct 259 ms 22240 KB Output is correct
7 Correct 102 ms 8268 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 126 ms 14204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 15 ms 1888 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 174 ms 21960 KB Output isn't correct
2 Halted 0 ms 0 KB -