# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
106167 | xiaowuc1 | Ice Hockey World Championship (CEOI15_bobek) | C++14 | 369 ms | 20952 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 <algorithm>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> plli;
typedef vector<vector<ll>> matrix;
void gen(vector<ll>& init, vector<ll>& ret) {
for(int mask = 0; mask < 1 << init.size(); mask++) {
ll curr = 0;
for(int i = 0; i < init.size(); i++) {
if(mask&(1LL<<i)) curr += init[i];
}
ret.push_back(curr);
}
sort(ret.begin(), ret.end());
}
void solve() {
int n;
ll thresh;
cin >> n >> thresh;
vector<ll> a, b;
for(int i = 0; i < n; i++) {
ll t;
cin >> t;
(i%2?a:b).push_back(t);
}
vector<ll> ar, br;
gen(a, ar);
gen(b, br);
ll ret = 0;
int j = br.size()-1;
for(int i = 0; i < ar.size() && j >= 0; i++) {
while(j >= 0 && ar[i] + br[j] > thresh) j--;
ret += j+1;
}
cout << ret << endl;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
/*
int t;
cin >> t;
for(int i = 1; i <= t; i++) {
cout << "Case #" << i << ": ";
solve();
}
*/
solve();
}
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... |