This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include "books.h"
using namespace std;
typedef long long ll;
ll adj[100001];
vector<int> ans;
void solve(int n, int k, ll a, int s) {
for(int i=1; i<=n; i++) adj[i]=skim(i);
int p=lower_bound(adj+1, adj+n+1, a)-adj;
p--;
if(p<=k-2) impossible();
if(p==k-1) {
ll sum=0;
for(int i=1; i<=k; i++) {
sum+=adj[i];
ans.push_back(i);
}
int idx=k+1;
while(idx<=n && sum<a) {
sum-=adj[idx-1];
sum+=adj[idx];
ans.pop_back();
ans.push_back(idx);
idx++;
}
if(sum>=a && sum<=a*2) answer(ans);
else impossible();
}
ll sum=0;
for(int i=1; i<=k; i++) sum+=adj[k];
int idx=k+1;
while(idx<=min(p+1, n) && sum<a) {
sum-=adj[idx-k];
sum+=adj[idx];
idx++;
}
if(sum<a || sum>a*2) impossible();
for(int i=idx-k+1; i<=idx; i++) ans.push_back(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... |