Submission #402245

#TimeUsernameProblemLanguageResultExecution timeMemory
402245Atill83A Difficult(y) Choice (BOI21_books)C++14
10 / 100
3 ms968 KiB
#include <bits/stdc++.h> #include "books.h" using namespace std; const int MAXN = (int) 1e5+5; typedef long long ll; ll arr[MAXN]; int k; ll ask(int idx){ if(arr[idx] != -1) return arr[idx]; return arr[idx] = skim(idx); } ll ask(vector<int> a){ ll res = 0; for(int j: a){ res += ask(j); } return res; } vector<int> get(int idx){ vector<int> ans; for(int i = idx; i < idx + k; i++) ans.push_back(i); return ans; } void solve(int N, int K, long long A, int S) { k = K; memset(arr, -1, sizeof(arr)); int l = 1, r = N - K + 1; while(l < r){ int m = (l + r) / 2; ll res = ask(get(m)); if(res >= A && res <= 2*A){ l = m; r = m; }else if(res < A){ l = m + 1; }else if(res > 2*A){ r = m - 1; } } l = min(l, N - K + 1); if(ask(get(l)) >= A && ask(get(l)) <= 2*A){ answer(get(l)); }else{ 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...