이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include <books.h>
#define sz(v) (int)v.size()
#define pb push_back
using namespace std;
typedef long long ll;
const int N = 1e5 + 1;
bool asked[N];
ll x[N];
ll ask (int i) {
if (asked[i]) return x[i];
asked[i] = true;
x[i] = skim(i);
return x[i];
}
void solve(int n,int k,ll A,int s){
for (int i = 1; i <= n; i++) {
asked[i] = false;
}
int l = 1, r = n, R = 0;
while (l <= r) {
int mid = (l + r) / 2;
if (ask(mid) > A + A) r = mid - 1;
else R = mid, l = mid + 1;
}
l = 1, r = R;
int L = 0;
while (l <= r) {
int mid = (l + r) / 2;
if (ask(mid) > A) r = mid - 1;
else L = mid, l = mid + 1;
}
ll sum = 0;
vector <int> ans;
for (int i = 1; i <= min(L, k); i++) {
if (sum + ask(i) > A + A) break;
sum += ask(i);
ans.pb(i);
}
if (sz(ans) < k - 1){
impossible();
}
if (L < R){
if (sum + ask(L + 1) <= A + A){
sum += ask(L + 1);
ans.pb(L + 1);
}
}
if (sz(ans) < k){
impossible();
}
else {
answer(ans);
}
}
# | 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... |