이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iterator>
#include <limits>
#include <list>
#include <cstring>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <unordered_map>
#include "books.h"
using namespace std;
typedef int ll;
typedef vector<ll> vi;
typedef pair<ll,ll> ii;
#ifdef px
#define p(x) cerr<<#x<<' '<<x<<endl;
#else
#define p(x) {}
#endif
#define F first
#define S second
#define sz size
#define ls s,m,idx<<1
#define rs m+1,e,idx<<1|1
const ll MOD=ll(1e9)+7;
const ll MAXN=2*ll(1e6);
//
// --- 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.
//
void solve(int N, int K, long long A, int S) {
// TODO implement this function
vi X(N+1,ll());
vi ans;
queue<ll> q;
ll sum=0;
for(ll i=1;i<=N;i++){
X[i]=skim(i);
}
for(ll i=1;i<=K;i++){
sum+=X[i];
q.push(X[i]);
}
ll last=K+1;
while(last<=N){
bool ok=(sum>=A&&sum<=2*A);
if(ok){
while(!q.empty()){
ans.push_back(q.front());
q.pop();
}
answer(ans);
}
sum-=q.front();
sum+=X[last];
q.pop();
q.push(X[last]);
last++;
}
bool ok=(sum>=A&&sum<=2*A);
if(ok){
while(!q.empty()){
ans.push_back(q.front());
q.pop();
}
answer(ans);
}
ans.clear();
sum=0;
for(ll i=1;i<K;i++){sum+=X[i];ans.push_back(X[i]);}
for(ll i=K;i<=N;i++){
if(X[i]>A){
sum+=X[i];
ans.push_back(X[i]);
break;
}
}
if(sum>=A&&sum<=2*A)answer(ans);
impossible();
}
# | 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... |