Submission #652481

#TimeUsernameProblemLanguageResultExecution timeMemory
652481flappybirdA Difficult(y) Choice (BOI21_books)C++17
0 / 100
1 ms312 KiB
#include <bits/stdc++.h> #include "books.h" typedef long long ll; using namespace std; #define MAX 101010 ll arr[MAX]; ll query(int x) { if (arr[x]) return arr[x]; return arr[x] = skim(x); } void solve(int N, int K, long long A, int S) { int i; ll sum = 0; for (i = 1; i < K; i++) sum += query(i); int l, r; l = K; r = N + 1; while (r - l > 1) { int mid = (l + r) / 2; if (query(mid) + sum > 2ll * A) r = mid; else l = mid; } if (sum + query(l) > 2ll * A) { impossible(); return; } if (sum + query(l) >= A) { vector<int> v; int i; for (i = 1; i < K; i++) v.push_back(i); v.push_back(l); answer(v); } for (i = K; i >= 0; i--) { int j; ll sum = 0; for (j = 1; j <= i; j++) sum += query(i); for (j = 1; j <= K - i; j++) sum += query(l - j + 1); if (sum <= 2 * A) { vector<int> v; for (j = 1; j <= i; j++) v.push_back(i); for (j = 1; j <= K - i; j++) v.push_back(l - j + 1); answer(v); return; } } }
#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...