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

10320번 - Button Bashing 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 256 MB242807235.821%

문제

You recently acquired a new microwave, and noticed that it provides a large number of buttons to be able to quickly specify the time that the microwave should be running for. There are buttons both for adding time, and for subtracting time. You wonder how efficient you can be when entering cooking times: you want to minimize the number of required button presses.

The microwave can be running for at least 0 seconds, and at most 1 hour. If a button press would result in a cooking time of less than 0 seconds, the microwave will set the cooking time to 0 seconds. If a button press would result in a cooking time of more than 1 hour, the microwave will set the cooking time to 1 hour. Initially, the microwave will run for 0 seconds. There will always be a button adding at least 1 second to the cooking time.

Given the buttons that the microwave provides for entering cooking times, determine the least amount of button presses required to let the microwave run for a certain amount of time. If it is not possible to enter the desired cooking time precisely, determine the smallest achievable cooking time above the target, and the minimum number of button presses required for that cooking time, instead. The microwave does not allow to adjust the cooking time once it has started cooking.

입력

On the first line one positive number: the number of test cases, at most 100. After that per test case:

  • one line with two space-separated integers n and t (1 ≤ n ≤ 16 and 0 ≤ t ≤ 3 600): the number of buttons available to change the cooking time, and the desired cooking time in seconds, respectively.
  • one line with n space-separated integers bi (−3 600 ≤ bi ≤ 3 600): the number of seconds added to the cooking time when button i is pressed.

출력

Per test case:

  • one line with two space-separated integers: the minimum number of button presses required to reach the required cooking time, and the minimum number of extra seconds that the microwave must be running for, respectively.

제한

예제 입력 1

2
3 50
-10 10 60
1 50
20

예제 출력 1

2 0
3 10

힌트

출처

ICPC > Regionals > Europe > Northwestern European Regional Contest > Benelux Algorithm Programming Contest > BAPC 2014 B번

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

출처

대학교 대회

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

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