이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "books.h"
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define sc second
using namespace std;
typedef long long int ll;
typedef string str;
vector<ll> v;
ll Skim(int in){
if(v[in] == -1) v[in] = skim(in+1);
return v[in];
}
void solve(int n, int k, ll A, int S){
if(S > 200) exit(-1);
if(k > n) impossible();
v.resize(n, -1);
ll s = 0;
for(int i = 0; i < k-1; i++) s+=Skim(i);
vector<int> ans;
if(s <= 2*A){
int a = k-1, b = n-1;
while(a < b){
int md = (a+b)/2;
if(Skim(md) >= A) b = md;
else a = md+1;
}
if(s+Skim(a) >= A && s+Skim(a) <= 2*A){
for(int i = 0; i < k-1; i++) ans.pb(i+1);
ans.pb(a+1);
answer(ans);
}
}
auto segment_skim = [&](int in){
ll s = 0;
for(int i = in; i < in+k; i++) s+=Skim(i);
return s;
};
int a = 0, b = n-k;
while(a <= b){
int md = (a+b)/2;
ll cur = segment_skim(md);
if(cur < A) a = md+1;
else if(cur > 2*A) b = md-1;
else{
for(int i = md; i < md+k; i++) ans.pb(i+1);
answer(ans);
}
}
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... |