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"
#include <bits/stdc++.h>
using namespace std;
void solve(int N, int K, long long A, int S) {
vector <long long> res(N + 1);
int l = 0, r = N + 1;
while(r - l > 1) {
int m = (l + r) / 2;
if((res[m] = skim(m)) >= A) {
r = m;
}
else {
l = m;
}
}
int ind = r;
cout << ind << " " << res[ind] << "\n";
// first way
long long sum = 0;
for(int i = 1; i <= K; i++) {
if(!res[i]) res[i] = skim(i);
sum += res[i];
if(i == K - 1 and ind <= N and res[ind] + sum <= 2 * A) {
vector <int> ans;
for(int i = 1; i < K; i++) {
ans.push_back(i);
}
ans.push_back(ind);
answer(ans);
return;
}
}
for(int i = max(1, ind - K); i < ind; i++) {
if(!res[i]) res[i] = skim(i);
}
for(int i = 1; i <= K + 1; i++) {
if(sum >= A and sum <= 2 * A) { // print
vector <int> ans;
for(int j = i; j <= K; j++) ans.push_back(j);
for(int j = 1; j < i; j++) ans.push_back(ind - j);
answer(ans);
return;
}
if(ind - i < 0) break;
if(i <= K and ind - i >= 1) {
sum -= res[i];
sum += res[ind - i];
}
}
impossible();
}
# | 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... |