이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "books.h"
#include<vector>
#include<cstdio>
#include<set>
#include<cstdlib>
#include<cstdarg>
#include<cassert>
#include<bits/stdc++.h>
typedef long long ll;
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.
//
void solve(int N, int K, long long A, int S) {
// TODO implement this function
vector<long long> vals;
for(int i = 1; i <= N; i++){
long long curr_diff = skim(i);
vals.push_back(curr_diff);
}
ll sum = 0;
deque<int> ans;
vector<int> res;
for(int i = 0; i < K; i++){
ans.push_back(i+1);
sum += vals[i];
}
if(sum >= A && sum <= 2*A){
for(int i = 0; i < K; i++) res.push_back(ans[i]);
answer(res);
}
ans.pop_back();
sum -= vals[K-1];
int last = N;
for(int j = 0; j <= last-K; j++){
for(int i = j+K-1; i < last; i++){
sum += vals[i];
ans.push_back(i+1);
// test
if(sum >= A && sum <= 2*A){
for(int k = 0; k < K; k++) res.push_back(ans[k]);
answer(res);
}
sum -= vals[i];
ans.pop_back();
if(sum+vals[i] > 2*A) last = i;
}
sum -= vals[j];
ans.pop_front();
sum += vals[j+K-1];
ans.push_back(j+K);
}
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... |