제출 #528872

#제출 시각아이디문제언어결과실행 시간메모리
528872OttoTheDinoA Difficult(y) Choice (BOI21_books)C++17
0 / 100
1 ms280 KiB
#include <bits/stdc++.h> #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. // #define rep(i,s,e) for (int i = s; i <= e; ++i) #define all(a) a.begin(), a.end() typedef long long ll; const int mx = 2e5; int x[mx]; void solve(int n, int k, long long a, int S) { vector<int> ans(k); iota(all(ans),1); ll s = 0; rep (i,1,k) { x[i] = skim(i); s += x[i]; } if (s>2*a) impossible(); else if (s>=a) { answer(ans); return; } else { int lo = k+1, hi = n+1; while (lo<hi) { int mid = (lo+hi)/2; x[mid] = skim(mid); if (x[mid]>=a) hi = mid; else lo = mid+1; } if (lo!=n+1) { if (s+x[lo]-x[k]<=2*n) { ans[k-1] = lo; answer(ans); return; } } rep (i,1,k) { x[n-i+1] = skim(n-i+1); s += x[n-i+1] - x[k-i+1]; ans[k-i] = n-i+1; if (s>=a) { answer(ans); return; } } } 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...