# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
436172 | cpp219 | Ice Hockey World Championship (CEOI15_bobek) | C++14 | 447 ms | 20852 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.
#pragma GCC optimization O2
#pragma GCC optimization "unroll-loop"
#pragma target ("avx2")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define fs first
#define sc second
using namespace std;
typedef pair<ll,ll> LL;
const ll N = 40 + 9;
const ll inf = 1e9 + 7;
vector<ll> v1,v2;
ll n,k,now,ans,a[N];
void f1(ll i){
if (i > n/2){
if (now <= k) v1.push_back(now);
return;
}
f1(i + 1); now += a[i]; f1(i + 1); now -= a[i];
}
void f2(ll i){
if (i > n){
if (now <= k) v2.push_back(now);
return;
}
f2(i + 1); now += a[i]; f2(i + 1); now -= a[i];
}
int main(){
ios_base::sync_with_stdio(NULL); cin.tie(0); cout.tie(0);
#define task "test"
if (fopen(task".INP","r")){
freopen(task".INP","r",stdin);
//freopen(task".OUT","w",stdout);
}
cin>>n>>k;
for (ll i = 1;i <= n;i++) cin>>a[i];
f1(1); now = 0; f2(n/2 + 1);
//for (auto i : v2) cout<<i<<" "; return 0;
sort(v2.begin(),v2.end());
for (auto i : v1){
ll inc = prev(upper_bound(v2.begin(),v2.end(),k - i)) - v2.begin() + 1;
//cout<<inc<<"x\n";
ans += inc;
}
cout<<ans;
}
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... |