# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
575329 | birthdaycake | A Difficult(y) Choice (BOI21_books) | C++17 | 3096 ms | 1656 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;
long long b[200001];
void solve(int n, int k, long long a, int s) {
if(s == n){
set<long long>v; long long a1 = 0, a2 = 0, a3 = -1;
for(int i = 0; i < n; i++) {
b[i] = skim(i + 1);
v.insert(b[i]);
}
for(int i = 0; i < n; i++){
for(int j = i + 1; j < n; j++){
long long tot = a - (b[i] + b[j]) - 1;
auto x = v.upper_bound(tot);
if(x != v.end() && *x == b[i]) x = v.upper_bound(*x);
if(x != v.end() && *x == b[j]) x = v.upper_bound(*x);
if(x != v.end()){
if(*x + b[i] + b[j] <= a * 2 && *x + b[i] + b[j] >= a ){
a1 = i; a2 = j;
a3 = *x;
}
}
}
}
for(int i = 0; i < n; i++){
if(a3 == b[i]){
vector<int>fin = {i + 1, a1 + 1, a2 + 1};
answer(fin);
}
}
impossible();
}else{
int l = 1, r = n - k + 1;
while(l <= r){
long long mid = (l + r) / 2, tot = 0;
vector<int>fin;
for(int i = mid; i <= mid + k - 1 ;i++){
if(b[i] == 0) b[i] = skim(i);
tot += b[i];
fin.push_back(i);
}
if(tot >= a && tot <= 2 * a){
answer(fin);
}
if(tot > 2 * a){
r = mid - 1;
}else{
l = mid + 1;
}
}
impossible();
}
}
Compilation message (stderr)
# | 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... |