# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
742526 | MODDI | Ice Hockey World Championship (CEOI15_bobek) | C++14 | 297 ms | 20808 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 pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<long long, long long> pll;
typedef pair<int,int> pii;
typedef vector<long long> vl;
typedef vector<int> vi;
int n;
ll m;
bool check_bit(int n, int bit){
int ok = n & (1 << bit);
if(ok) return true;
return false;
}
int main(){
cin>>n>>m;
vl arr(n+1);
for(int i =1; i <= n; i++) cin>>arr[i];
vl msk1, msk2;
int k = n / 2;
for(int i = 0; i < (1 << k); i++){
ll sum = 0;
for(int j = 0; j < k; j++){
if(check_bit(i, j))
sum += arr[j+1];
}
msk1.pb(sum);
}
for(int i = 0; i < (1 << n - k); i++){
ll sum = 0;
for(int j = 0; j < n-k; j++){
if(check_bit(i, j))
sum += arr[j+k+1];
}
msk2.pb(sum);
}
sort(msk1.begin(), msk1.end());
sort(msk2.begin(), msk2.end());
int j = 0;
ll ans = 0;
for(int i = msk1.size()-1; i >= 0; i--){
while(j < msk2.size() && msk2[j] + msk1[i] <= m) j++;
ans += 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... |