Submission #1286599

#TimeUsernameProblemLanguageResultExecution timeMemory
1286599SmuggingSpunA Difficult(y) Choice (BOI21_books)C++20
0 / 100
2 ms1080 KiB
#include <bits/stdc++.h> #include "books.h" using namespace std; typedef long long ll; const int lim = 1e5 + 5; ll cost[lim]; ll get(int i){ if(cost[i] != -1){ return cost[i]; } return cost[i] = skim(i); } void solve(int n, int k, ll A, int S){ memset(cost, -1, sizeof(cost)); if(S == n){ for(int i = 1; i <= n; i++){ get(i); } ll pref = accumulate(cost + 1, cost + k + 1, 0LL); if(pref > (A << 1LL)){ impossible(); return; } vector<int>ans; if(pref >= A){ for(int i = 1; i <= k; i++){ ans.push_back(i); } answer(ans); return; } ll sum = pref; for(int i = n, j = k; i > j && j > 0; i--){ ll alt = sum - cost[j] + cost[i]; if(alt <= (A << 1LL)){ if(alt >= A){ for(int t = j; t > 0; t--){ ans.push_back(t); } answer(ans); return; } pref -= cost[j]; sum = alt; ans.push_back(i); } } impossible(); 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...