이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define fs first
#define sc second
#include "books.h"
using namespace std;
void solve(int n, int k, long long a, int s) {
vector<pair<int,int> > v;
long long p=0;
for(int i=1;i<k;i++){
v.push_back({skim(i),i});
p+=v.back().fs;
}
int l=k,r=n;
while(r>l){
int m=(l+r+1)/2;
long long z=skim(m)+p;
if(z>2*a){
r=m-1;
}
else if(a<=z){
vector<int> ans;
for(int i=1;i<k;i++){
ans.push_back(i);
}
ans.push_back(m);
answer(ans);
return;
}
else{
l=m;
}
}
vector<pair<int,int> > c;
c.push_back({skim(l),l});
for(int i=l-1;i>l-k;i--){
c.push_back({skim(i),i});
}
reverse(c.begin(),c.end());
for(int i=0;i<k;i++){
long long z=0;
for(int j=0;j<i;j++){
z+=v[j].fs;
}
for(int j=i;j<k;j++){
z+=c[j].sc;
}
if(2*a >= z && z>=a){
vector<int> ans;
for(int j=0;j<i;j++){
ans.push_back(v[j].sc);
}
for(int j=i;j<k;j++){
ans.push_back(c[j].sc);
}
answer(ans);
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... |