제출 #969039

#제출 시각아이디문제언어결과실행 시간메모리
969039NotLinuxA Difficult(y) Choice (BOI21_books)C++17
0 / 100
1 ms1112 KiB
#include <bits/stdc++.h> #include "books.h" using namespace std; vector < long long > dp; long long ask(int p){ if(dp[p] == -1)dp[p] = skim(p); return dp[p]; } void solve(int N, int K, long long A, int S) { dp.assign(N + 1 , -1); vector < long long > v = {0}; // cout << "flag0" << endl; for(int i = 1;i<=K;i++){ int res = ask(i); v.push_back(res + v.back()); } // cout << "flag1" << endl; auto is_valid = [&](int x){ if(x >= A and x <= A * 2)return true; else return false; }; if(v[K] > 2 * A)impossible(); else if(v[K] >= A){ vector < int > v(K); iota(v.begin() , v.end() , 1); answer(v); } else{ int l = 1 , r = N+1 , tar = A; while(l < r){ int mid = (l + r) >> 1; if(ask(mid) < tar){ l = mid+1; } else{ r = mid; } } // cout << "bs results : " << l << endl; if((l - K) <= 0)impossible(); if(l <= N and is_valid(ask(l) + v[K-1])){ vector < int > v(K); iota(v.begin() , v.end() , 1); v[K-1] = l; answer(v); } // cout << "flag2" << endl; long long sum = 0; for(int i = 1;i<=K;i++){ sum += ask(l - i); // cout << i << " : " << sum + v[K - i] << endl; if(is_valid(sum + v[K - i])){ vector < int > ans; for(int j = l - i;j<l;j++){ ans.push_back(j); } for(int j = 1;j <= K - i;j++){ ans.push_back(j); } 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...