Logo
(追記) (追記ここまで)

27610번 - A Musical Question 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
11 초 1024 MB47343075.000%

문제

Bob Roberts likes to listen to music while he drives, but the car he owns is a little antiquated. No Bluetooth or USB connections here, but at least he has a CD player, so he's been transferring a lot of his music to CDs. At the moment he has only two CDs left and would like to get as much of his remaining music as possible on them. Given the capacity of the CDs and collection of songs, can you help him find the maximum number of minutes of music he can put on the two CDs?

입력

Input starts with a line containing two integers $c$ $n,ドル where $c$ $(1 \leq c\leq 1,000円)$ is the number of minutes of music each CD can hold, and $n$ $(1 \leq n \leq 1,000円)$ is the number of songs to select from. Following this is a single line containing $n$ positive integers indicating the length (in minutes) of each of the songs. No song will be longer than 1ドル,000円$ minutes.

출력

Output the amount of music on each CD, in minutes, that maximizes the total amount of music that Bob can transfer to the two CDs. Display the time of the larger-filled CD first. If there is a tie, use the solution which minimizes the time difference between the two CDs.

제한

예제 입력 1

100 5
10 20 40 60 85

예제 출력 1

100 95

예제 입력 2

100 5
10 20 30 40 50

예제 출력 2

80 70

힌트

출처

ICPC > Regionals > North America > East Central North America Regional > 2022-2023 East Central Regional Contest B번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /