RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
ICPC00028

F. Low Power

Unrated 레이팅 미적용
난이도
4s
시간 제한
1024MB
메모리 제한
0
맞았습니다!!
0
제출 수
0.0%
정답률
레이팅

의견: 0

설명

You are building advanced chips for machines. Making the chips is easy, but the power supply turns out to be an issue since the available batteries have varied power outputs. Consider the problem of \(n\) machines, each with two chips, where each chip is powered by \(k\) batteries. Surprisingly, it does not matter how much power each chip gets, but a machine works best when its two chips have power outputs as close as possible. The power output of a chip is simply the smallest power output of its \(k\) batteries. You have a stockpile of 2\(nk\) batteries that you want to assign to the chips. It might not be possible to allocate the batteries so that in every machine both chips have equal power outputs, but you want to allocate them so that the differences are as small as possible. To be precise, you want to tell your customers that in all machines the difference of power outputs of the two chips is at most \(d\), and you want to make \(d\) as small as possible. To do this you must determine an optimal allocation of the batteries to the machines. Consider Sample Input 1. There are 2 machines, each requiring 3 batteries per chip, and a supply of batteries with power outputs 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12. You can, for instance, assign the batteries with power outputs 1, 3, 5 to one chip, those with power 2, 4, 12 to the other chip of the same machine, those with power 6, 8, 9 to the third chip, and those with power 7, 10, 11 to the fourth. The power outputs of the chips are 1, 2, 6, and 7, respectively, and the difference between power outputs is 1 in both machines. Note that there are many other ways to achieve this result.

제약
입력 형식

The input consists of a single test case. A test case consists of two lines. The first line contains two positive integers: the number of machines \(n\) and the number of batteries per chip \(k\) (2\(nk \le 10^{6}\)). The second line contains 2\(nk\) integers \(pi\) specifying the power outputs of the batteries (\(1 \le pi \le 10^{9}\)).

출력 형식

Display the smallest number \(d\) such that you can allocate the batteries so that the difference of power outputs of the two chips in each machine is at most \(d\).

예제 1
입력
2 3
1 2 3 4 5 6 7 8 9 10 11 12
출력
1
예제 2
입력
2 2
3 1 3 3 3 3 3 3
출력
2
문제 정보

생성자가 기록되지 않았습니다.

출처 ICPC World Finals 2013

평가 및 의견

F. Low Power

개요
출제자 난이도 Unrated 레이팅 미적용 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

F. Low Power

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8