# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
803467 | raysh07 | Ice Hockey World Championship (CEOI15_bobek) | C++17 | 58 ms | 31156 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
#define INF (int)1e18
#define f first
#define s second
mt19937_64 RNG(chrono::steady_clock::now().time_since_epoch().count());
vector <int> gen(vector <int> a){
vector <int> v;
v.push_back(0);
for (auto x : a){
vector <int> nv;
int p1 = 0;
for (auto y : v){
while (v[p1] + x < y){
nv.push_back(v[p1] + x);
p1++;
}
nv.push_back(y);
}
while (p1 != v.size()){
nv.push_back(v[p1] + x);
p1++;
}
v = nv;
}
return v;
}
void Solve()
{
int n, m; cin >> n >> m;
vector <int> a, b;
for (int i = 0; i < n; i++){
int x; cin >> x;
if (i < 20){
a.push_back(x);
} else {
b.push_back(x);
}
}
vector <int> v1 = gen(a);
vector <int> v2 = gen(b);
// sort(v1.begin(), v1.end());
// sort(v2.begin(), v2.end());
int ptr = 0;
int ans = 0;
reverse(v1.begin(), v1.end());
for (auto x : v1){
while (ptr != v2.size() && x + v2[ptr] <= m){
ptr++;
}
ans += ptr;
}
cout << ans << "\n";
}
int32_t main()
{
auto begin = std::chrono::high_resolution_clock::now();
ios_base::sync_with_stdio(0);
cin.tie(0);
int t = 1;
// cin >> t;
for(int i = 1; i <= t; i++)
{
//cout << "Case #" << i << ": ";
Solve();
}
auto end = std::chrono::high_resolution_clock::now();
auto elapsed = std::chrono::duration_cast<std::chrono::nanoseconds>(end - begin);
cerr << "Time measured: " << elapsed.count() * 1e-9 << " seconds.\n";
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... |