이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "books.h"
#define taskname "test"
#define fi first
#define se second
#define pb push_back
#define faster ios_base::sync_with_stdio(0); cin.tie(0);
using namespace std;
using ll = long long;
using pii = pair <ll, ll>;
using pil = pair <ll, ll>;
using pli = pair <ll, ll>;
using pll = pair <ll, ll>;
using ull = unsigned ll;
ll min(const ll &a, const ll &b){
return (a < b) ? a : b;
}
ll max(const ll &a, const ll &b){
return (a > b) ? a : b;
}
//const ll Mod = 1000000009;
//const ll Mod2 = 999999999989;
//only use when required
const ll maxN = 1e5 + 1;
ll n, k, a, s;
vector <pll> tem;
vector <int> ans;
void solve(int N, int K, ll A, int S){
n = N; k = K; a = A; s = S;
ll sum = 0;
for (ll i = 1; i <= k; ++i){
tem.pb({i, skim(i)});
sum += tem.back().se;
}
if (sum > 2 * a) impossible();
if (a <= sum && sum <= 2 * a){
for (auto i: tem) ans.pb(i.fi);
answer(ans);
}
ll l = 1, r = n;
while (l <= r){
ll mid = (l + r) / 2;
if (skim(mid) >= a) r = mid - 1;
else l = mid + 1;
}
if (r <= k) impossible();
++r;
if (r <= n){
sum = skim(r);
for (ll i = 0; i < k - 1; ++i) sum += tem[i].se;
if (sum <= 2 * a){
for (ll i = 1; i < k; ++i) ans.pb(i);
ans.pb(r);
answer(ans);
}
}
--r;
if (r == k) impossible();
sum = 0;
ll atr = skim(r);
for (ll i = 1; i < k; ++i) sum += tem[i].se;
if (sum + atr >= a){
for (ll i = 2; i <= k; ++i) ans.pb(i);
ans.pb(r);
answer(ans);
}
tem.pb({r, atr});
sum = atr;
ans.pb(r);
for (ll i = r - 1; i > max(k, r - k) && sum < a; --i){
tem.pb({i, skim(i)});
ans.pb(i);
sum += tem.back().se;
}
if (sum < a) impossible();
int tt = ans.size();
for (ll i = 1; i <= k - tt; ++i){
ans.pb(i);
}
answer(ans);
}
# | 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... |