# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
863666 | Cyber_Wolf | A Difficult(y) Choice (BOI21_books) | C++17 | 3060 ms | 696 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"
#ifdef CYBER
#include "grader.cpp"
#endif
#define lg long long
using namespace std;
const lg N = 2e5+5;
lg v[N], n,k, a, s;
vector<int> ans, cur;
bool solve(lg idx, lg sum = 0)
{
if(cur.size() > k) return false;
if(sum > 2*a) return false;
if(idx > n)
{
if(sum <= 2*a && sum >= a)
{
ans = cur;
return true;
}
return false;
}
cur.push_back(idx);
if(solve(idx+1, sum+v[idx]))
{
return true;
}
cur.pop_back();
if(solve(idx+1, sum)) return true;
return false;
}
void solve(int N, int K, long long A, int S)
{
n = N;
k = K;
a = A;
s = S;
for(int i = 1; i <= N; i++)
{
v[i] = skim(i);
}
solve(1);
if(ans.empty()) impossible();
answer(ans);
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... |