Submission #529834

#TimeUsernameProblemLanguageResultExecution timeMemory
529834mjhmjh1104A Difficult(y) Choice (BOI21_books)C++17
100 / 100
1 ms288 KiB
#include <map> #include "books.h" using namespace std; map<int, long long> m; int s; long long get(int x, int K) { long long ret = 0; for (int i = 0; i < K; i++) { if (m.find(x + i + 1) == m.end()) m[x + i + 1] = skim(x + i + 1); ret += m[x + i + 1]; if (ret > (long long)4e18) ret = (long long)4e18; } return ret; } void solve(int N, int K, long long A, int S) { int l = 0, r = N; while (l < r) { int m = (l + r) / 2; if ((m == N ? (long long)4e18 : get(m, 1)) < A) l = m + 1; else r = m; } if (l < N && l >= K - 1 && get(l, 1) + get(0, K - 1) >= A && get(l, 1) + get(0, K - 1) <= 2 * A) { vector<int> v; for (int i = 0; i < K - 1; i++) v.push_back(i + 1); v.push_back(l + 1); answer(v); return; } if (l >= K) for (int i = 0; i <= K; i++) if (get(0, i) + get(l - K + i, K - i) >= A && get(0, i) + get(l - K + i, K - i) <= 2 * A) { vector<int> v; for (int j = 0; j < i; j++) v.push_back(j + 1); for (int j = 0; j < K - i; j++) v.push_back(l - K + i + j + 1); answer(v); 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...