이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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[id];
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;
}
id--;
}
/*for(int i=0;i<ans.size();i++) cout<<ans[i]<<" ";
cout<<endl;
cout<<sk<<endl;*/
}
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... |