File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ // https://www.acmicpc.net/problem/3079
2+
3+ #include < algorithm>
4+ #include < iostream>
5+
6+ using namespace std ;
7+
8+ int M, N;
9+ long long Tk[100001 ]; // 각 심사대에서 심사를 하는데 걸리는 시간
10+ long long maxTime = 0 ;
11+
12+ long long binary_search () {
13+ long long start = 1 ;
14+ long long end = M * maxTime; // M * Tk
15+ long long res = M * maxTime;
16+
17+ while (start <= end) {
18+ long long sum = 0 ; // 심사할 수 있는 친구들 수
19+ long long mid = (start + end) / 2 ;
20+
21+ for (int i = 0 ; i < N; i++) {
22+ sum += (mid / Tk[i]);
23+ if (sum > M) break ;
24+ }
25+
26+ if (sum >= M) {
27+ end = mid - 1 ;
28+ res = min (res, mid);
29+ }
30+ else {
31+ start = mid + 1 ;
32+ }
33+ }
34+ return res;
35+ }
36+
37+ int main () {
38+ ios::sync_with_stdio (false );
39+ cin.tie (NULL ), cout.tie (NULL );
40+
41+ cin >> N >> M;
42+ for (int i = 0 ; i < N; i++) {
43+ cin >> Tk[i];
44+ maxTime = max (maxTime, Tk[i]);
45+ }
46+ cout << binary_search ();
47+ }
You can’t perform that action at this time.
0 commit comments