Submission #858959

# Submission time Handle Problem Language Result Execution time Memory
858959 2023-10-09T13:08:26 Z Tenis0206 Ice Hockey World Championship (CEOI15_bobek) C++11
100 / 100
283 ms 22212 KB
#include <bits/stdc++.h>
#define int long long

using namespace std;

const int nmax = 40;

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

signed 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:52:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |     for(int i=0;i<a.size();i++)
      |                 ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory 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
# Verdict Execution time Memory Grader output
1 Correct 0 ms 412 KB Output is correct
2 Correct 0 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 0 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory 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
# Verdict Execution time Memory Grader output
1 Correct 22 ms 2144 KB Output is correct
2 Correct 66 ms 5512 KB Output is correct
3 Correct 283 ms 21316 KB Output is correct
4 Correct 64 ms 5576 KB Output is correct
5 Correct 11 ms 1752 KB Output is correct
6 Correct 7 ms 992 KB Output is correct
7 Correct 15 ms 1624 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 30 ms 3032 KB Output is correct
2 Correct 23 ms 2144 KB Output is correct
3 Correct 115 ms 11968 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 6 ms 1040 KB Output is correct
6 Correct 15 ms 1500 KB Output is correct
7 Correct 15 ms 1500 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 47 ms 3676 KB Output is correct
2 Correct 96 ms 7512 KB Output is correct
3 Correct 96 ms 8040 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 69 ms 8036 KB Output is correct
6 Correct 237 ms 21420 KB Output is correct
7 Correct 96 ms 7244 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 197 ms 14084 KB Output is correct
2 Correct 22 ms 2140 KB Output is correct
3 Correct 8 ms 1116 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 6 ms 1116 KB Output is correct
6 Correct 194 ms 14792 KB Output is correct
7 Correct 15 ms 1500 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 22 ms 2396 KB Output is correct
2 Correct 64 ms 5456 KB Output is correct
3 Correct 8 ms 1112 KB Output is correct
4 Correct 7 ms 992 KB Output is correct
5 Correct 67 ms 7008 KB Output is correct
6 Correct 22 ms 2144 KB Output is correct
7 Correct 264 ms 21336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 277 ms 22212 KB Output is correct
2 Correct 23 ms 2144 KB Output is correct
3 Correct 8 ms 1116 KB Output is correct
4 Correct 276 ms 22160 KB Output is correct
5 Correct 91 ms 11452 KB Output is correct
6 Correct 15 ms 1508 KB Output is correct
7 Correct 30 ms 3032 KB Output is correct