이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "books.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n, k;
ll arr[100002];
ll arr2[100002];
int s, lim;
void solve(int N, int K, ll A, int S){
n = N, k = K, s = S, lim = A;
for(int i=1; i<=k; i++) arr[i] = skim(i);
int MIN = 1, MAX = n, LOC = n+1;
ll VAL = 1e18;
while(MIN <= MAX){
int MID = (MIN + MAX) / 2;
ll tmp = skim(MID);
if(tmp >= A){
VAL = tmp;
LOC = MID;
MAX = MID-1;
}
else MIN = MID+1;
}
if(LOC != n+1){
ll sum = 0;
for(int i=1; i<k; i++) sum += arr[i];
sum += VAL;
if(A <= sum && sum <= A+A){
vector<int> v;
for(int i=1; i<k; i++) v.push_back(i);
v.push_back(LOC);
answer(v);
return;
}
}
LOC--;
if(LOC < k) impossible();
for(int i=1; i<=k; i++){
arr2[i] = skim(LOC+1-i);
}
for(int i=0; i<=k; i++){
ll sum = 0;
for(int j=1; j<=i; j++) sum += arr[j];
for(int j=1; j<=k-i; j++) sum += arr2[j];
if(A <= sum && sum <= A+A){
vector<int> v;
for(int j=1; j<=i; j++) v.push_back(j);
for(int j=1; j<=k-i; j++) v.push_back(LOC+1-j);
answer(v);
return;
}
}
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... |