Submission #1101393

# Submission time Handle Problem Language Result Execution time Memory
1101393 2024-10-16T08:06:41 Z 0pt1mus23 Ice Hockey World Championship (CEOI15_bobek) C++14
100 / 100
324 ms 22964 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define ins insert      
#define pb push_back
#define endl '\n'
#define putr(x) cout<<x<<endl;return; 
#define all(x) x.begin(),x.end()
#define _ << " " <<
mt19937 rng(time(0));

const int mod = 1e9 +9,
        sze = 2e5 +23,
        inf = INT_MAX,
        LL = 20;

void _0x0(){
    int n,m;
    cin>>n>>m;
    vector<int> arr(n);
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    vector<int> lst;
    vector<int> lst2;
    int ans=1;
    vector<int> a,b;

    for(int i=0;i<n/2;i++){
        a.pb(arr[i]);
    }

    for(int i =n/2;i<n;i++){
        b.pb(arr[i]);
    }
    // for(auto v:a) cout<<v<<" ";cout<<endl;
    // for(auto v:b) cout<<v<<" ";cout<<endl;
    for(int mask=0;mask<(1<<(a.size()));mask++){
        int sum=0;
        for(int j=0;j<a.size();j++){
            if(mask & (1<<j)){
                sum+=a[j];
            }
        }
        lst.pb(sum);
    }
    for(int mask=0;mask<(1<<(b.size()));mask++){
        int sum=0;
        for(int j=0;j<b.size();j++){
            if(mask & (1<<j)){
                sum+=b[j];
            }
        }
        lst2.pb(sum);
    }
    sort(all(lst));
    sort(all(lst2));
    for(auto v:lst){
        auto lazim = m - v;
        if(lazim>=0){
            ans+= ( upper_bound(all(lst2),lazim) - lst2.begin() ) ;
        }
    }
    cout<<ans-1<<endl;
}

signed main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int tt = 1;

    // cin>>tt;
    while(tt--){
        _0x0();
    }
 
    return 0;
}

Compilation message

bobek.cpp: In function 'void _0x0()':
bobek.cpp:40:22: 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]
   40 |         for(int j=0;j<a.size();j++){
      |                     ~^~~~~~~~~
bobek.cpp:49:22: 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]
   49 |         for(int j=0;j<b.size();j++){
      |                     ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 508 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 508 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 508 KB Output is correct
7 Correct 1 ms 508 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 26 ms 2132 KB Output is correct
2 Correct 82 ms 6448 KB Output is correct
3 Correct 324 ms 22836 KB Output is correct
4 Correct 78 ms 6596 KB Output is correct
5 Correct 15 ms 1644 KB Output is correct
6 Correct 8 ms 1108 KB Output is correct
7 Correct 17 ms 1748 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 38 ms 3020 KB Output is correct
2 Correct 28 ms 2136 KB Output is correct
3 Correct 137 ms 12628 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 7 ms 1104 KB Output is correct
6 Correct 18 ms 1676 KB Output is correct
7 Correct 19 ms 1504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 56 ms 4608 KB Output is correct
2 Correct 111 ms 8620 KB Output is correct
3 Correct 116 ms 8656 KB Output is correct
4 Correct 1 ms 352 KB Output is correct
5 Correct 78 ms 8780 KB Output is correct
6 Correct 281 ms 22856 KB Output is correct
7 Correct 104 ms 8664 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 243 ms 14908 KB Output is correct
2 Correct 31 ms 2136 KB Output is correct
3 Correct 10 ms 1108 KB Output is correct
4 Correct 1 ms 596 KB Output is correct
5 Correct 7 ms 1108 KB Output is correct
6 Correct 230 ms 14912 KB Output is correct
7 Correct 17 ms 1748 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 27 ms 2132 KB Output is correct
2 Correct 73 ms 6608 KB Output is correct
3 Correct 9 ms 1108 KB Output is correct
4 Correct 10 ms 1108 KB Output is correct
5 Correct 80 ms 8800 KB Output is correct
6 Correct 27 ms 2136 KB Output is correct
7 Correct 273 ms 22868 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 297 ms 22868 KB Output is correct
2 Correct 27 ms 2136 KB Output is correct
3 Correct 9 ms 1108 KB Output is correct
4 Correct 311 ms 22964 KB Output is correct
5 Correct 112 ms 12624 KB Output is correct
6 Correct 18 ms 1844 KB Output is correct
7 Correct 33 ms 3024 KB Output is correct