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;
//
// --- Sample implementation for the task books ---
//
// To compile this program with the sample grader, place:
// books.h books_sample.cpp sample_grader.cpp
// in a single folder and run:
// g++ books_sample.cpp sample_grader.cpp
// in this folder.
//
typedef long long ll;
const int MAX_N=1e5+10;
vector<ll> book;
void solve(int N, int K, long long A, int S) {
book.push_back(0);
for(int i=1;i<=N;i++){
book.push_back(skim(i));
}
ll sk=0;
vector<int> ans;
for(int i=1;i<K;i++){
sk+=book[i];
ans.push_back(i);
}
if(sk>=A){
if(sk+book[K]>2*A) impossible();
else{
ans.push_back(K);
answer(ans);
}
}
bool ok=0;
auto it=upper_bound(book.begin(),book.end(),A);
it--;
int id=it-book.begin();
if(sk+book[id]>=A && sk+book[id]<=2LL*A){
ans.push_back(id);
ok=1;
}
else{
sk-=book[1];
sk+=book[id];
ans.erase(ans.begin());
ans.push_back(id);
id--;
for(int i=0;i<K-1;i++){
int mi=ans[0];
ans.erase(ans.begin());
ans.push_back(id);
sk-=book[mi]; sk+=book[id];
if(sk>=A){
ok=1;
break;
}
}
}
if(!ok) impossible();
else 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... |