제출 #667417

#제출 시각아이디문제언어결과실행 시간메모리
667417someoneA Difficult(y) Choice (BOI21_books)C++14
100 / 100
3 ms336 KiB
#include "books.h" #include <bits/stdc++.h> #define ll long long using namespace std; const int MAXN = 2e5 + 42; ll val[MAXN]; ll get(int i) { if(val[i] == 0) val[i] = skim(i); return val[i]; } int dicho(int deb, int fin, int maxi) { if(deb + 1 == fin) return deb; int med = (deb + fin) >> 1; if(get(med) <= maxi) return dicho(med, fin, maxi); return dicho(deb, med, maxi); } void solve(int N, int K, ll A, int S) { vector<int> ans; ll sum = 0; for(int i = 1; i <= K; i++) sum += get(i); int last = K; for(int j = 18; j >= 0; j--) if(last + (1 << j) <= N && sum + get(last + (1 << j)) - get(K) <= 2*A) last += (1 << j); for(int i = K; i > 0; i--) { if(sum + get(last + i - K) - get(i) <= 2*A) { sum += get(last + i - K) - get(i); ans.push_back(last + i - K); } else { impossible(); } if(sum >= A) { for(int j = 1; j < i; j++) ans.push_back(j); 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...