Submission #813067

# Submission time Handle Problem Language Result Execution time Memory
813067 2023-08-07T13:07:36 Z JakobZorz Ice Hockey World Championship (CEOI15_bobek) C++14
100 / 100
302 ms 20812 KB
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <set>
#include <stack>
#include <limits.h>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <cstring>
#include <sstream>
 
#pragma GCC target("popcnt")
 
typedef long long ll;
typedef long double ld;
using namespace std;
const int MOD=1e9+7;
typedef pair<ll,ll>point;
//#define x first
//#define y second
 
ll arr1[20];
ll arr2[20];
int n;
ll m;
int n1,n2;

int main(){
    ios::sync_with_stdio(false);
    cout.tie(NULL);
    cin.tie(NULL);
    
    cin>>n>>m;
    n1=n/2;
    n2=n-n/2;
    for(int i=0;i<n1;i++)
        cin>>arr1[i];
    for(int i=0;i<n2;i++)
        cin>>arr2[i];
    
    vector<ll>values1;
    for(int bits1=0;bits1<(1<<n1);bits1++){
        ll val=0;
        for(int i=0;i<n1;i++)
            if(bits1&(1<<i))
                val+=arr1[i];
        values1.push_back(val);
    }
    sort(values1.begin(),values1.end());
    
    vector<ll>values2;
    for(int bits2=0;bits2<(1<<n2);bits2++){
        ll val=0;
        for(int i=0;i<n2;i++)
            if(bits2&(1<<i))
                val+=arr2[i];
        values2.push_back(val);
    }
    sort(values2.begin(),values2.end());
    
    ll res=0;
    int i=(int)values2.size();
    for(ll val:values1){
        while(i>0&&values2[i-1]+val>m)
            i--;
        res+=i;
    }
    
    cout<<res<<"\n";
    return 0;
}

/*
 
5 1000
100 1500 500 500 1000
 
 */
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 320 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 320 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 320 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 23 ms 2008 KB Output is correct
2 Correct 72 ms 5440 KB Output is correct
3 Correct 302 ms 20812 KB Output is correct
4 Correct 70 ms 5440 KB Output is correct
5 Correct 12 ms 1596 KB Output is correct
6 Correct 8 ms 984 KB Output is correct
7 Correct 16 ms 1600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 32 ms 2908 KB Output is correct
2 Correct 26 ms 2000 KB Output is correct
3 Correct 122 ms 10564 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 6 ms 976 KB Output is correct
6 Correct 16 ms 1596 KB Output is correct
7 Correct 17 ms 1576 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 55 ms 3516 KB Output is correct
2 Correct 104 ms 6604 KB Output is correct
3 Correct 105 ms 6664 KB Output is correct
4 Correct 0 ms 320 KB Output is correct
5 Correct 71 ms 6592 KB Output is correct
6 Correct 273 ms 20744 KB Output is correct
7 Correct 103 ms 6580 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 218 ms 12704 KB Output is correct
2 Correct 24 ms 1992 KB Output is correct
3 Correct 8 ms 984 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 6 ms 984 KB Output is correct
6 Correct 213 ms 12768 KB Output is correct
7 Correct 15 ms 1620 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 24 ms 2008 KB Output is correct
2 Correct 68 ms 5444 KB Output is correct
3 Correct 8 ms 984 KB Output is correct
4 Correct 8 ms 964 KB Output is correct
5 Correct 76 ms 6544 KB Output is correct
6 Correct 26 ms 1976 KB Output is correct
7 Correct 301 ms 20776 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 291 ms 20752 KB Output is correct
2 Correct 25 ms 2008 KB Output is correct
3 Correct 8 ms 984 KB Output is correct
4 Correct 300 ms 20736 KB Output is correct
5 Correct 104 ms 10568 KB Output is correct
6 Correct 16 ms 1620 KB Output is correct
7 Correct 32 ms 2896 KB Output is correct