제출 #424004

#제출 시각아이디문제언어결과실행 시간메모리
424004zoooma13A Difficult(y) Choice (BOI21_books)C++14
100 / 100
1 ms328 KiB
#include <bits/stdc++.h> #include "books.h" using namespace std; map <int ,long long> mem; long long ask(int i){ if(mem.count(i)) return mem[i]; return mem[i] = skim(i); } vector <int> range(int l ,int r){ vector <int> ret; for(int i = l; i <= r; i++) ret.push_back(i); return ret; } void solve(int N, int K, long long A, int S) { int l = 1 ,r = N ,m; while(l <= r){ m = (l+r)>>1; if(ask(m) > A/K) r = m-1; else l = m+1; } r = max(K ,l); l = r-K+1; long long tot = 0; for(int i = l; i <= r; i++) tot += ask(i); while(tot <= 2*A){ if(tot >= A) answer(range(l ,r)); if(r == N) impossible(); tot += ask(++r); tot -= ask(l++); } auto ans = range(1 ,K-1); ans.push_back(r); tot = 0; for(int&i : ans) tot += ask(i); if(A <= tot && tot <= 2*A) answer(ans); 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...