| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 850686 | vjudge1 | A Difficult(y) Choice (BOI21_books) | C++17 | 2 ms | 1236 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;
//
// --- 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> x(N+1);
for(long long i = 1; i<= N; i++) x[i] = skim(i);
vector<pair<long long,long long>> ans;
vector<long long> in;
map<long long,long long> idx;
x[0] = x[1];
for(long long i = 0; i<=N; i++) idx[x[i]] = i;
vector<long long> used(N+1);
for(long long i = 1; i<=N; i++){
long long s = 2*A; s-=x[i];
long long a = *lower_bound(x.begin(),x.end(),s);
if(x[i] + a <= 4*A && !used[i] && !used[idx[a]]) ans.push_back({min(idx[a],i),max(i,idx[a])}), used[i] = 1, used[idx[a]] =1;
if(A <= x[i] && x[i] <= 2*A) in.push_back(i);
}
if(2*ans.size() < K - 1){
impossible();
return;
}
vector<long long> used1(N+1);
vector<int> ans1;
for(long long i = 0; i<K/2; i++){
used1[ans[i].first] = used1[ans[i].second] = 1;
ans1.push_back(ans[i].first); ans1.push_back(ans[i].second);
}
if(K%2 == 1){
for(long long i : in){
if(!used1[i]){
ans1.push_back(i); break;
}
}
}
if(ans1.size() != K) impossible();
else answer(ans1);
}
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... | ||||
