# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
130716 | nandonathaniel | Ice Hockey World Championship (CEOI15_bobek) | C++14 | 426 ms | 20948 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>
using namespace std;
typedef long long LL;
const LL MOD=1000000007;
vector<LL> pertama,kedua;
LL a[25],b[25];
int main(){
ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
LL n,m,ans=0;
cin >> n >> m;
LL first=n/2,second=n-first;
for(LL i=0;i<first;i++)cin >> a[i];
for(LL i=0;i<second;i++)cin >> b[i];
for(LL i=0;i<(1<<first);i++){
LL brp=0;
for(LL j=0;j<first;j++){
if(i & (1<<j))brp+=a[j];
}
pertama.push_back(brp);
}
for(LL i=0;i<(1<<second);i++){
LL brp=0;
for(LL j=0;j<second;j++){
if(i & (1<<j))brp+=b[j];
}
kedua.push_back(brp);
}
sort(pertama.begin(),pertama.end());
sort(kedua.begin(),kedua.end());
reverse(kedua.begin(),kedua.end());
LL j=0;
for(LL i=0;i<pertama.size();i++){
while(j<kedua.size() && kedua[j]+pertama[i]>m)j++;
ans+=(kedua.size()-j);
}
cout << ans << 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... |