이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define intt long long
#define forr(i , x , y) for(int i = x ;i <= y;i++)
#define pb push_back
#define fore(i , n) for(int i = 0 ; i <n;i++)
/**
* skims through the i-th book and returns its difficulty x_i (1 <= i <= N).
*/
long long skim(int);
/**
* buys your selection of books. This function has to be called with
* v = {i_1, ..., i_K} (1 <= i_1, ..., i_K <= N) where the i_j's are pairwise
* distinct and satisfy A <= x_{i_1} + ... + x_{i_K} <= 2 A.
*/
void answer(std::vector<int>);
/**
* states that it is impossible to buy a set of K books with the desired difficulty.
*/
void impossible();
void solve(int n, int k, long long a, int s)
{
vector<intt> x(n + 1);
vector<intt> pref(n + 1);
forr(i , 1,n)
{
x[i] = skim(i);
pref[i] = x[i] + pref[i - 1];
}
vector<int> ans;
forr(i , 1 , n)
{
if(x[i] >= a)
{
if(k - 1 < i && pref[k - 1] + x[i] <= 2 * a)
{
forr(j , 1 , k - 1)
ans.pb(j);
ans.pb(i);
answer(ans);
return;
}
}
}
forr(i , k , n)
{
if(x[i]>= a)
break;
if(a <= pref[i] - pref[i - k] && pref[i] - pref[i - k] <= 2ll * a)
{
forr(j , i - k + 1 , i)
{
ans.pb(j);
}
answer(ans);
return ;
}
}
impossible();
}
# | 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... |