Submission #414111

# Submission time Handle Problem Language Result Execution time Memory
414111 2021-05-30T04:18:10 Z Pichon5 Ice Hockey World Championship (CEOI15_bobek) C++17
100 / 100
490 ms 20780 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/2;i++){
        cin>>x;
        A.pb(x);
    }
    for(int i=0;i<(n+1)/2;i++){
        cin>>x;
        B.pb(x);
    }
    n=A.size();
    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);
        }
    }
    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();e--;
        int pos=-1;
        while(b<=e){
            int mid=(b+e)/2;
            if(SB[i]+SA[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:57:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |     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 204 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 1 ms 204 KB Output is correct
2 Correct 1 ms 204 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 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 2 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 292 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 35 ms 1960 KB Output is correct
2 Correct 113 ms 5388 KB Output is correct
3 Correct 489 ms 20780 KB Output is correct
4 Correct 105 ms 5388 KB Output is correct
5 Correct 15 ms 1476 KB Output is correct
6 Correct 9 ms 844 KB Output is correct
7 Correct 8 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 48 ms 2880 KB Output is correct
2 Correct 41 ms 1864 KB Output is correct
3 Correct 202 ms 10448 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 7 ms 844 KB Output is correct
6 Correct 15 ms 1480 KB Output is correct
7 Correct 10 ms 296 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 77 ms 3396 KB Output is correct
2 Correct 175 ms 6580 KB Output is correct
3 Correct 160 ms 6580 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 84 ms 6560 KB Output is correct
6 Correct 272 ms 20764 KB Output is correct
7 Correct 49 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 344 ms 12736 KB Output is correct
2 Correct 33 ms 1992 KB Output is correct
3 Correct 12 ms 940 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 8 ms 844 KB Output is correct
6 Correct 191 ms 12672 KB Output is correct
7 Correct 8 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 35 ms 1908 KB Output is correct
2 Correct 103 ms 5416 KB Output is correct
3 Correct 11 ms 844 KB Output is correct
4 Correct 11 ms 844 KB Output is correct
5 Correct 97 ms 6584 KB Output is correct
6 Correct 21 ms 1856 KB Output is correct
7 Correct 127 ms 272 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 437 ms 20716 KB Output is correct
2 Correct 37 ms 1864 KB Output is correct
3 Correct 11 ms 964 KB Output is correct
4 Correct 490 ms 20772 KB Output is correct
5 Correct 118 ms 10532 KB Output is correct
6 Correct 16 ms 1552 KB Output is correct
7 Correct 17 ms 204 KB Output is correct