Submission #992624

#TimeUsernameProblemLanguageResultExecution timeMemory
992624amin_2008A Difficult(y) Choice (BOI21_books)C++17
0 / 100
2 ms344 KiB
#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); for(int i = 1; i <= N; i++) cout << a[i] << ' '; cout << endl; 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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...