# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
414111 | Pichon5 | Ice Hockey World Championship (CEOI15_bobek) | C++17 | 490 ms | 20780 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |