# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
863488 | Ahmed_Solyman | A Difficult(y) Choice (BOI21_books) | C++14 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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) {
// TODO implement this function
vector<ll>v;
for(int i=1;i<=n;i++){
v.push_back(skim(i));
}
for(int i=0;i<n;i++){
for(int j=i+1;j<n;j++){
ll sum=v[i]+v[j];
int z=upper_bound(v.begin(),v.end(),a*2-sum)-v.begin();
z--;
while(z==i || z==j)k--;
if(z<0 || v[i]+v[j]+v[z]<){
continue;
}
answer({i+1,j+1,k+1});
return;
}
}
impossible();
}