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

11372번 - Gimli’s Gullet 다국어

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

문제

Legolas and Gimli are packing rations before setting off from the Woodland Realm, but the kitchen seems to have underestimated the belly of a dwarf! Gimli absolutely refuses to set off until the matter is settled and his pack is at its maximal hunger-satisfying potential, lest his Dwarven appetite go unsated.

입력

Input consists of several test cases, each over multiple lines. The first line of every test case contains a single non-negative integer, denoting the space (in cubic centimeters) remaining in Gimli’s pack. The second line contains a single non-negative integer, M, describing the number of food items available. The next M lines each consist of two non-negative integers, describing the volume (also in cubic centimeters) and caloric content of a food, respectively. These lines are sorted in increasing order of volume.

A test case starting with 0 cubic centimeters denotes end of input, and should not produce output.

출력

For each test case, output a single space-separated line with M entries. Each entry in the line is the quantity that Gimli should order of the corresponding food from the kitchen in order to fill his pack with the maximum amount of food.

제한

예제 입력 1

6000
4
230 100
350 500
480 900
1400 2000
760
2
10 180
200 300
0

예제 출력 1

0 2 11 0
76 0

힌트

출처

School > University of Virginia High School Programming Contest > UVa HSPC 2014 H번

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

출처

대학교 대회

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

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