/* Set a binary value to mid: 1. Dry clothes with an AI value less than or equal to mid; 2. For a dress whose AI value is greater than the mid value, the minimum time is to use a machine for a period of time and dry it for a period of time. Set these two periods to X1 and X2 respectively, so there is mid = X1 + X2, AI <= K * X1 + X2, solve x1> = (AI-mid)/(k-1), SO (AI-mid) /(k-1) rounded up is the minimum time of the dress. */# Include <stdio. h> # include <string. h> # include <algorithm> # include <stdlib. h> # include <math. h> using namespace STD; int A [100010]; int N, K; int check (int x) {int COT = 0; // drying time for (INT I = 0; I <n; I ++) {if (a [I] <= x) // blow dry continue; cot + = (INT) Ceil (double) (A [I]-x)/(k-1); // rounded up if (COT> X) return false;} return true;} int main () {int I, Cot, count; char s [25]; while (~ Scanf ("% d", & N) {for (I = 0; I <n; I ++) scanf ("% d", & A [I]); scanf ("% d", & K); sort (A, A + n); COT = 0; Count = 0; int L = 0; int r = A [n-1]; If (K! = 1) {While (L <= r) {int mid = (L + r)/2; If (check (MID) r = mid-1; elsel = Mid + 1;} printf ("% d \ n", L);} elseprintf ("% d \ n", a [n-1]);} return 0 ;}