제출 #722530

#제출 시각아이디문제언어결과실행 시간메모리
722530lovrotA Difficult(y) Choice (BOI21_books)C++17
0 / 100
1 ms296 KiB
#include <bits/stdc++.h> #include "books.h" #define X first #define Y second #define pb push_back using namespace std; typedef long long ll; typedef pair<int, int> pii; // g++ books_sample.cpp sample_grader.cpp void solve(int n, int k, long long a, int s) { vector<int> ans; vector<pair<int, ll>> v1, v2; int lo = 1, hi = n + 1; while(hi - lo > 1) { int mi = (lo + hi) / 2; if(skim(mi) >= a) hi = mi; else lo = mi; } ll sum = skim(hi); if(hi != n + 1 && sum <= 2 * a) { ans.pb(hi); for(int i = 1; i < k; i++) { ll res = skim(i); sum += res; ans.pb(i); v1.pb({i,res}); } if(sum <= 2 * a) { answer(ans); return; } } sum = 0; ans.clear(); v1.pb({k, skim(k)}); for(int i = hi - 1; i && k; i--, k--) { v2.pb({i, skim(i)}); sum += v2.back().Y; ans.pb(i); } if(sum >= a && sum <= 2 * a) { answer(ans); return; } for(pair<int, ll> p : v1) { sum -= v2.back().Y; sum += p.Y; ans.pop_back(); ans.pb(p.X); if(sum >= a && sum <= 2 * 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...