제출 #1064167

#제출 시각아이디문제언어결과실행 시간메모리
1064167vjudge1A Difficult(y) Choice (BOI21_books)C++17
0 / 100
1 ms344 KiB
#include <bits/stdc++.h> #include "books.h" using namespace std; typedef long long ll; typedef pair<int, int> pii; #define pb push_back #define F first #define S second #define sz(x) (int)x.size() const int N = 5e5; ll n, k, mx; void solve(int N, int K, long long A, int S) { n = N; k = K; mx = A; int lo = 0, hi = n + 1; while(lo + 1 < hi){ int m = (lo + hi) / 2; ll x = skim(m); if(x > A) hi = m; else lo = m; } if(hi < k) impossible(); vector<pair<ll, ll>> ha = {}; if(2 * k < hi){ for(int i = 1; i <= k; i++){ ha.pb({i, skim(i)}); } for(int i = hi - k; i < hi; i++){ ha.pb({i, skim(i)}); } }else{ for(int i = 1; i < hi; i++) ha.pb({i, skim(i)}); } ll sm = 0; if(hi <= n){ sm += skim(hi); for(int i = 1; i < k; i++){ sm += ha[i - 1].S; } if(sm >= A && sm <= 2 * A){ vector<int> ret = {}; for(int i = 1; i < k; i++) ret.pb(i); ret.pb(hi); answer(ret); return; } } sm = 0; int cur = k - 2; while(sm < A){ cur++; if(cur == sz(ha)) break; sm = 0; for(int i = cur - k + 1; i <= cur; i++) sm += ha[i].S; } if(cur == sz(ha)) impossible(); vector<int> ret = {}; for(int i = cur - k + 1; i <= cur; i++) ret.pb(i + 1); answer(ret); }
#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...