제출 #531926

#제출 시각아이디문제언어결과실행 시간메모리
5319264fectaA Difficult(y) Choice (BOI21_books)C++17
100 / 100
2 ms1864 KiB
#include <bits/stdc++.h> #include "books.h" using namespace std; #define ll long long #define int ll #define ld long double #define pii pair<int, int> #define f first #define s second #define boost() cin.tie(0), cin.sync_with_stdio(0) int h[100005], in[100005]; void solve(int32_t n, int32_t k, int a, int32_t s) { memset(h, 0, sizeof(h)); memset(in, 0, sizeof(in)); vector<int32_t> ret; int sum = 0; for (int i = 1; i < k; i++) { h[i] = skim(i); sum += h[i]; in[i] = 1; } int lo = k, hi = n, mid; while (lo < hi) { mid = (lo + hi + 1) / 2; h[mid] = skim(mid); if (sum + h[mid] > 2 * a) hi = mid - 1; else lo = mid; } h[lo] = skim(lo); in[lo] = 1; sum += h[lo]; if (sum > 2 * a) impossible(); if (sum >= a) { for (int i = 0; i < 100005; i++) if (in[i]) ret.push_back(i); answer(ret); } for (int i = 1; i < k; i++) { h[lo - i] = skim(lo - i); sum += h[lo - i] - h[k - i]; in[k - i] = 0, in[lo - i] = 1; if (sum >= a) { for (int j = 0; j < 100005; j++) if (in[j]) ret.push_back(j); answer(ret); } } impossible(); }
#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...