이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <fstream>
#include <cstdio>
#include <queue>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <map>
#include <cassert>
#include <unordered_map>
#include <set>
#include <stack>
#include <cstring>
#include <cmath>
#include <bitset>
#include <random>
#include <numeric>
#include <cstdlib>
#include "books.h"
using namespace std;
//
// --- Sample implementation for the task books ---
//
// To compile this program with the sample grader, place:
// books.h books_sample.cpp sample_grader.cpp
// in a single folder and run:
// g++ books_sample.cpp sample_grader.cpp
// in this folder.
//
const int sz = 2e5 + 5;
int a[sz];
struct SegTree
{
vector<int> tree;
SegTree(int n)
{
tree.resize(n << 2);
}
void build(int l, int r, int in)
{
if (l == r)
{
tree[in] = a[l];
return;
}
int mid = (l + r) >> 1;
build(l, mid, in << 1);
build(mid + 1, r, in << 1 | 1);
tree[in] = tree[in << 1] + tree[in << 1 | 1];
}
int get(int lx, int rx, int l, int r, int in)
{
if (lx > rx or lx > r or rx < l) return 0;
if (l >= lx and r <= rx) return tree[in];
int mid = (l + r) >> 1;
return get(lx, rx, l, mid, in << 1) + get(lx, rx, mid + 1, r, in << 1 | 1);
}
};
void solve(int N, int K, long long A, int S) {
for(int i = 1; i <= N; i++) a[i] = skim(i);
SegTree st(N);
st.build(1, N, 1);
for(int i = 1; i <= N; i++) if (st.get(i, i + K, 1, N, 1) >= A and st.get(i, i + K - 1, 1, N, 1) <= 2 * A)
{
vector<int> res;
for(int j = i; j <= i + K - 1; j++) res.push_back(a[j]);
answer(res);
return;
}
impossible();
}
// 15 3 42 15
// 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
# | 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... |