이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#include "books.h"
#define fi first
#define se second
#define pitem item*
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
const int N=1e6+10;
const int SS=1<<19;
const int INFi=2e9;
const ll INFl=1e18;
const ll mod2=998244353;
const ll mod=1e9+7;
const ll mod3=1000696969;
const ll p=70032301;
const ull p2=913;
const int L=20;
ll t[N];
ll que(int a){
if(t[a]) return t[a];
t[a]=skim(a);
return t[a];
}
void solve(int n,int k,ll a,int s){
int pocz=1,kon=n,sr,res=n+1;
while(pocz<=kon){
sr=(pocz+kon)>>1;
if(que(sr)>=a) res=sr,kon=sr-1;
else pocz=sr+1;
}
if(res<k){
impossible();
return;
}
ll last=(res==n+1?INFl:que(res));
ll sum=0;
for(int i=1;i<k;i++) sum+=que(i);
sum+=last;
vi ans;
if(sum>=a and sum<=(a<<1LL)){
for(int i=1;i<k;i++) ans.push_back(i);
ans.push_back(res);
answer(ans);
return;
}
if(res==k){
impossible();
return;
}
sum-=last;
sum+=que(k);
ll sum2=0;
res--;
for(int i=res;i>=res-k+1;i--) sum2+=que(i);
if(sum>(a<<1LL) or sum2<a){
impossible();
return;
}
for(int i=1;i<=k;i++){
int dr=res-i+1;
if(dr<=k or sum>=a){
ans.push_back(i);
continue;
}
ans.push_back(dr);
sum+=t[dr]-t[i];
}
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... |