#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.
//
void solve(int N, int K, long long A, int S) {
// TODO implement this function
assert(N<=1000 && S==N && K==3);
vector<long long> X(N);
for(int i=0;i<N;i++){
X[i]=skim(i+1);
}
long long maximum=A-1;
vector<int> vec={0,0,0};
for(int i=0;i<N-2;i++){
for(int j=i+1;j<N-1;j++){
long long l=2*A-X[i]-X[j];
if(X[j+1]>l){
break;
}
int t=upper_bound(X.begin()+j+1,X.end(),l)-X.begin();
if(maximum<X[i]+X[j]+X[t-1]){
maximum=X[i]+X[j]+X[t-1];
vec={i+1,j+1,t};
}
}
}
if(maximum<A){
impossible();
return;
}
answer(vec);
}
# | 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... |