제출 #992646

#제출 시각아이디문제언어결과실행 시간메모리
992646amin_2008A Difficult(y) Choice (BOI21_books)C++17
0 / 100
4 ms1212 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. // void solve(int N, int K, long long A, int S) { int lg[N + 5]; lg[1] = 0; for(int i = 2; i < N + 5; i++) lg[i] = lg[i >> 1] + 1; int a[N + 5]; for(int i = 1; i <= N; i++) a[i] = skim(i); vector<vector<int > > mat; mat.assign(lg[N] + 1, vector<int>(N + 1, 0)); for(int i = 1; i <= N; i++) mat[0][i] = a[i]; for(int i = 1; i <= lg[N]; i++) for(int j = 1; j + (1LL << i) <= N; j++) mat[i][j] = mat[i - 1][j] + mat[i - 1][j + (1LL << (i - 1))]; for(int i = 1; i <= N; i++) { if (mat[lg[(i + K - 1) - i + 1]][i] + mat[lg[(i + K - 1) - i + 1]][(i + K - 1) - (1LL << lg[(i + K - 1) - i + 1]) + 1] >= A and mat[lg[(i + K - 1) - i + 1]][i] + mat[lg[(i + K - 1) - i + 1]][(i + K - 1) - (1LL << lg[(i + K - 1) - i + 1]) + 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...