이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "books.h"
using namespace std;
typedef long long ll;
//
// --- 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) {
vector<long long int>v(N);
for(int i = 1;i<=N;i++){
v[i-1] = skim(i);
}
ll sum = 0;
for(int i = 0;i<K;i++){
sum += v[i];
}
if(sum >= A && sum <= 2*A){
vector<int> ret;
for(int i = 1;i<=K;i++){
ret.push_back(i);
}
answer(ret);
}
if(sum > 2*A)impossible();
int crit = -1;
for(int i = 1;i<N - K + 1; i++){
sum -= v[i-1];
sum += v[i+K-1];
if(sum >= A && sum <= 2*A){
vector<int>ret;
for(int j = i;j<i+K;j++)ret.push_back(j + 1);
answer(ret);
}
if(sum >2*A){
crit = i;
break;
}
}
if(crit == -1)impossible();
else{
long long int s = 0;
for(int i = crit - 1;i<crit+K;i++){
s += v[i];
}
for(int i = crit-1;i<crit+K;i++){
if(s - v[i] <= 2*A && s-v[i] >= A){
vector<int>ret;
for(int j = crit - 1;j<crit+K;j++){
if(j != i){
ret.push_back(j+1);
}
}
answer(ret);
}
}
}
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... |