# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
863663 | Cyber_Wolf | A Difficult(y) Choice (BOI21_books) | C++17 | 32 ms | 1228 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>
#include "books.h"
#ifdef CYBER
#include "grader.cpp"
#endif
#define lg long long
using namespace std;
void solve(int N, int K, long long A, int S)
{
vector<lg> v(N);
for(int i = 1; i <= N; i++)
{
v[i] = skim(i);
}
vector<int> ans;
for(int i = 0; i+K-1 <= N; i++)
{
vector<int> cur(K);
lg sum = 0;
for(int j = 0; j < K; j++) cur[j] = i+j, sum += v[cur[j]];
while(sum <= 2*A)
{
if(sum >= A)
{
ans = cur;
break;
}
if(i == N) break;
priority_queue<array<lg, 2>> q;
q.push({v[i+K]-v[i+K-1], K-1});
// cout << sum << '\n';
while(q.size() && sum < A)
{
lg u = q.top()[1];
q.pop();
sum += v[cur[u]+1]-v[cur[u]];
// for(auto it : cur) cout << it << ' ';
// cout << '\n';
cur[u]++;
if(u+1 == cur.size() || cur[u+1] != cur[u]+1)
{
if(cur[u]+1 <= N) q.push({v[cur[u]+1]-v[cur[u]], u});
}
if(u-1 >= 0 && cur[u]-cur[u-1] == 2)
{
q.push({v[cur[u-1]+1]-v[cur[u-1]], u-1});
}
}
cout << "\n\n";
}
}
if(ans.empty()) impossible();
answer(ans);
impossible();
}
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... |