Submission #414108

# Submission time Handle Problem Language Result Execution time Memory
414108 2021-05-30T04:08:21 Z Pichon5 Ice Hockey World Championship (CEOI15_bobek) C++17
40 / 100
74 ms 8616 KB
#include<bits/stdc++.h>
#define lcm(a,b) (a/__gcd(a,b))*b
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define pb push_back
#define F first
#define S second
#define mp make_pair
using namespace std;

vll A;
vll B;
ll m,x,res=1,sum;
vll SA,SB;
int n;
int main()
{
    cin>>n;
    cin>>m;
    for(int i=0;i<n;i++){
        cin>>x;
        A.pb(x);
    }
    /*for(int i=0;i<(n+1)/2;i++){
        cin>>x;
        B.pb(x);
    }*/
    for(int i=0;i<(1<<n);i++){
        sum=0;
        for(int l=0;l<n;l++){
            if((1<<l)&i){
                sum+=A[l];
            }
        }
        if(sum<=m && sum>0){
            res++;
            SA.pb(sum);
        }
    }
    cout<<res<<endl;
    return 0;
    n=B.size();
    for(int i=0;i<(1<<n);i++){
        sum=0;
        for(int l=0;l<n;l++){
            if((1<<l)&i){
                sum+=B[l];
            }
        }
        if(sum<=m && sum>0){
            res++;
            SB.pb(sum);
        }
    }
    sort(SA.begin(),SA.end());
    for(int i=0;i<SB.size();i++){
        int b=0,e=SA.size()-1;
        int pos=-1;
        while(b<=e){
            int mid=(b+e)/2;
            if(SB[i]+SB[mid]<=m){
                pos=mid;
                b=mid+1;
            }else{
                e=mid-1;
            }
        }
        res+=pos+1;
    }
    cout<<res<<endl;


    return 0;
}

Compilation message

bobek.cpp: In function 'int main()':
bobek.cpp:58:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |     for(int i=0;i<SB.size();i++){
      |                 ~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 296 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 1348 KB Output is correct
2 Correct 5 ms 588 KB Output is correct
3 Correct 9 ms 840 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 7 ms 840 KB Output is correct
6 Correct 74 ms 8592 KB Output is correct
7 Correct 9 ms 292 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 73 ms 8616 KB Output is correct
2 Correct 18 ms 936 KB Output is correct
3 Correct 5 ms 928 KB Output is correct
4 Correct 5 ms 460 KB Output is correct
5 Correct 68 ms 4400 KB Output is correct
6 Correct 10 ms 1348 KB Output is correct
7 Correct 10 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -