이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "books.h"
#define DIM 100010
using namespace std;
int n,k,s,i;
long long a;
long long v[DIM],d[DIM];
/*void answer (vector<int> ans){
for (auto it : ans)
cout<<it<<" ";
return;
}
void impossible(){
cout<<"impossible";
}
long long skim (int poz){
return v[poz];
}
*/
void solve(int n, int k, long long a, int s) {
int i;
int sum = 0;
for (i=1;i<=k;i++){
d[i] = skim(i);
sum += d[i];
}
if (sum > 2*a){
impossible();
return;
}
vector <int> ans;
if (sum >= a){
for (i=1;i<=k;i++)
ans.push_back(i);
answer(ans);
return;
}
int st = 1, dr = n, poz = n+1;
while (st <= dr){
int mid = (st + dr) >> 1;
if (skim(mid) > a){
poz = mid;
dr = mid-1;
} else st = mid+1;
}
if (poz <= n){
ans.push_back(poz);
for (i=2;i<=k;i++)
ans.push_back(i);
} else {
int st = 1, dr = n;
while (sum < a && dr >= n-k+1){
sum -= d[st];
sum += skim(dr);
st++, dr--;
}
if (sum < a){
impossible();
return;
}
for (i=st;i<=k;i++)
ans.push_back(i);
for (i=dr+1;i<=n;i++)
ans.push_back(i);
}
sort (ans.begin(),ans.end());
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... |