# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1110487 | idk__ | Ice Hockey World Championship (CEOI15_bobek) | C++14 | 331 ms | 22976 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;
#define int long long
vector<int>sum1, sum2;
int n, x;
int a[41];
void f1(int i, int sum){
if(i==n/2){
sum1.push_back(sum);
return;
}
f1(i+1, sum+a[i]);
f1(i+1, sum);
}
void f2(int i, int sum){
if(i==n){
sum2.push_back(sum);
return;
}
f2(i+1, sum+a[i]);
f2(i+1, sum);
}
signed main() {
ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
cin >> n >> x;
for(int i = 0;i < n; i++)cin >> a[i];
f1(0, 0);
f2(n/2, 0);
sort(sum2.begin(), sum2.end());
int ans = 0;
for(auto i : sum1){
int idx = (upper_bound(sum2.begin(), sum2.end(), x-i) - sum2.begin());
auto it = upper_bound(sum2.begin(), sum2.end(), x-i);
ans += idx ;
}
cout << ans << endl;
}
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... |