Submission #852906

#TimeUsernameProblemLanguageResultExecution timeMemory
852906Trisanu_DasA Difficult(y) Choice (BOI21_books)C++17
100 / 100
1 ms600 KiB
#include <bits/stdc++.h> #include "books.h" using namespace std; long long a[100005]; void solve(int n, int k, long long A, int s) { for(int i = 1; i <= k; i++) a[i] = skim(i); long long sm = 0; for(int i = 1; i <= k; i++){ sm += a[i]; if(sm > 2 * A){ impossible(); return; } } int l = k, h = n, mid, ans; while(l <= h){ mid = (l + h)/2; if(skim(mid) + sm - a[k] <= 2 * A){ ans = mid; l = mid + 1; } else h = mid - 1; } int cur = k; for(int i = ans; i > ans-k; i --){ sm -= a[cur]; sm += skim(i); cur--; if(sm >= A){ vector<int> anss; for(int j = i; j <= ans; j++) anss.push_back(j); for(int j = 1; j <= cur; j++) anss.push_back(j); answer(anss); 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...