이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "books.h"
using namespace std;
#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(nullptr)
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define REP(n) FOR(O, 1, (n))
#define f first
#define s second
#define pb push_back
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<ll> vl;
const int MAXN = 1e5 + 100;
int n, k, s;
ll a;
unordered_map<int, ll> saved;
ll get (int i) {
if (saved[i] > 0)return saved[i];
saved[i] = skim(i);
return saved[i];
}
void solve(int N, int K, long long A, int S) {
n = N;
k = K;
a = A;
s = S;
vi ids;
FOR(i, 1, k) {
ids.pb(i);
}
//if (get() {
int le = 1, ri = n;
while (le < ri) {
int mid = (le+ri)/2;
if (get(mid) > a) ri = mid;
else le = mid+1;
}
le = max(le, k);
//cout << " le = " << le << endl;
ll cur = 0;
FOR(i, 1, k-1) cur += get(i);
cur += get(le);
if (a <= cur && cur <= 2*a) {
vi ret;
FOR(i, 1, k-1) ret.pb(i);
ret.pb(le);
answer(ret);
return;
}
FOR(i, max(k+1, le-k), le-1) ids.pb(i);
//}
int sz = (int)ids.size();
FOR(mask, 0, (1<<sz)-1) {
ll curS = 0;
vi ret;
int cnt = 0;
FOR(i, 0, sz-1) {
if (mask & (1<<i)) {
cnt++;
curS += get(ids[i]);
ret.pb(ids[i]);
}
}
if (cnt == k && a <= curS && curS <= 2*a) {
answer(ret);
return;
}
}
//answer(ret);
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... |