이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "books.h"
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int) x.size())
#define show(x) cerr << #x << " is " << x << endl;
#define show2(x, y) cerr << #x << " is " << x << ", " << #y << " is " << y << endl;
#define show3(x, y, z) cerr << #x << " is " << x << ", " << #y << " is " << y << ", " << #z << " is " << z << endl;
typedef long long lint;
typedef pair<lint, lint> ii;
lint smallest[14];
void solve(int n, int K, long long A, int S){
for(int i = 1;i <= K;i++) smallest[i] = skim(i);
lint X = 0;
for(int i = 1;i <= K-1;i++) X += smallest[i];
lint low = K-1, high = n+1;
while(low != high-1){
lint mid = (low+high)/2;
lint q = skim(mid);
if(X + q < A) low = mid;
else if(X + q > 2*A) high = mid;
else{
vector<int> res;
for(int i = 1;i <= K-1;i++) res.push_back(i);
res.push_back(mid);
answer(res);
return;
}
}
if(low == K-1) impossible();
X += smallest[K];
multiset<int> ress;
for(int i = 1;i <= K;i++) ress.insert(i);
for(int i = 1;i <= K;i++){
X -= smallest[K-i+1];
X += skim(low-i+1);
ress.erase(ress.find(K-i+1));
ress.insert(low-i+1);
if(A <= X and X <= 2*A){
vector<int> res;
for(int x : ress) res.push_back(x);
answer(res);
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... |