Submission #529130

#TimeUsernameProblemLanguageResultExecution timeMemory
52913079brueA Difficult(y) Choice (BOI21_books)C++14
100 / 100
1 ms400 KiB
#include "books.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; int n, k; ll arr[100002]; ll arr2[100002]; int s, lim; void solve(int N, int K, ll A, int S){ n = N, k = K, s = S, lim = A; for(int i=1; i<=k; i++) arr[i] = skim(i); int MIN = 1, MAX = n, LOC = n+1; ll VAL = 1e18; while(MIN <= MAX){ int MID = (MIN + MAX) / 2; ll tmp = skim(MID); if(tmp >= A){ VAL = tmp; LOC = MID; MAX = MID-1; } else MIN = MID+1; } if(LOC != n+1){ ll sum = 0; for(int i=1; i<k; i++) sum += arr[i]; sum += VAL; if(A <= sum && sum <= A+A){ vector<int> v; for(int i=1; i<k; i++) v.push_back(i); v.push_back(LOC); answer(v); return; } } LOC--; if(LOC < k) impossible(); for(int i=1; i<=k; i++){ arr2[i] = skim(LOC+1-i); } for(int i=0; i<=k; i++){ ll sum = 0; for(int j=1; j<=i; j++) sum += arr[j]; for(int j=1; j<=k-i; j++) sum += arr2[j]; if(A <= sum && sum <= A+A){ vector<int> v; for(int j=1; j<=i; j++) v.push_back(j); for(int j=1; j<=k-i; j++) v.push_back(LOC+1-j); 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...