Http://poj.org/problem? Id = 3104
Question:
There are n pieces of clothing, each piece of AI water, natural air drying less than 1 per minute, while drying Less Than k per minute. Obtain the shortest time for all dry tasks.
Ideas:
Note that there is no natural drying during drying.
Can be understood as drying every minute (k-1) of water.
In this way, each dress loses 1 water every minute.
The minimum value of the binary enumeration can be.
# Include <cstdio> # include <algorithm> using namespace STD; const int maxn = 100000 + 10; int A [maxn]; int N, K; bool OK (INT X) {int T = 0; For (INT I = n-1; I> = 0; I --) {if (a [I] <= x) break; else t = T + (A [I] + k-2-x)/(k-1); If (T> X) return false;} return true;} int main () {While (~ Scanf ("% d", & N) {for (INT I = 0; I <n; I ++) scanf ("% d ", & A [I]); scanf ("% d", & K); sort (A, A + n); If (k = 1) {printf ("% d \ n", a [n-1]); continue;} int ans; int L = 1, R = A [n-1]; while (L <= r) {int mid = L + (R-L)/2; If (OK (MID) {r = mid-1; ans = mid ;} elsel = Mid + 1;} printf ("% d \ n", ANS);} return 0 ;}