이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "books.h"
#define fr(i, a, b) for (int i = (a); i <= (b); i++)
#define rf(i, a, b) for (int i = (a); i >= (b); i--)
#define fe(x, y) for (auto& x : y)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define pw(x) (1LL << (x))
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
using namespace std;
mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count());
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <typename T>
using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define fbo find_by_order
#define ook order_of_key
template <typename T>
bool umn(T& a, T b) {
return a > b ? a = b, 1 : 0;
}
template <typename T>
bool umx(T& a, T b) {
return a < b ? a = b, 1 : 0;
}
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename T>
using ve = vector<T>;
const int N = 1e5 + 5;
ll what[N];
ll get(int i) {
if (what[i]) {
return what[i];
} else {
return what[i] = skim(i);
}
}
void solve(int N, int K, long long A, int S) {
fill(what + 1, what + 1 + N, 0);
int l = 1;
int r = N;
while (l < r) {
int mid = l + ((r - l) >> 1);
if (get(mid) >= A) {
r = mid;
} else {
l = mid + 1;
}
}
{
ll sum = 0;
sum += get(l);
if (sum < A) l++;
if (sum >= A && l > K - 1) {
fr (i, 1, K - 1) sum += get(i);
if (sum <= 2 * A) {
ve<int> ans;
fr (i, 1, K - 1) ans.pb(i);
ans.pb(l);
answer(ans);
}
}
}
fr (i, 1, K) {
what[i] = get(i);
}
fr (i, max(1, l - K), l - 1) {
what[i] = get(i);
}
ve<pll> v;
fr (i, 1, N) {
if (what[i]) {
v.pb({what[i], i});
}
}
fr (i, 0, sz(v) - K) {
ll sum = 0;
fr (j, i, i + K - 1) {
sum += v[j].fi;
}
if (sum >= A && sum <= 2 * A) {
ve<int> ans;
fr (j, i, i + K - 1) {
ans.pb(v[j].se);
}
answer(ans);
}
}
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... |