제출 #399084

#제출 시각아이디문제언어결과실행 시간메모리
399084egekabasA Difficult(y) Choice (BOI21_books)C++14
45 / 100
3 ms256 KiB
#include <bits/stdc++.h> #include "books.h" #define all(x) (x).begin(), (x).end() #define ff first #define ss second #define pb push_back #define mp make_pair using namespace std; typedef long long ll; typedef unsigned long long ull; typedef long double ld; typedef pair<ll, ll> pll; typedef pair<ull, ull> pull; typedef pair<int, int> pii; typedef pair<ld, ld> pld; // // --- 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 finish(deque<int> &ans){ vector<int> v; for(auto u : ans) v.pb(u); answer(v); } void solve(int N, int K, long long A, int S) { deque<int> ans; deque<ll> val; ll curval = 0; for(ll i = 1; i <= K; ++i){ ans.pb(i); val.pb(skim(i)); curval += val.back(); } if(curval > 2*A){ impossible(); return; } if(curval >= A){ finish(ans); return; } ll l = K+1, r = N; while(l < r){ ll m = (l+r+1)/2; if(curval-val[0]+skim(m) > 2*A) r = m-1; else l = m; } for(ll i = l; i > K && curval < A; --i){ ll addval = skim(i); if(addval <= val[0]) break; ans.pop_front(); curval -= val[0]; val.pop_front(); ans.pb(i); val.pb(addval); curval += addval; } if(curval >= A && 2*A >= curval) finish(ans); else 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...