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

3994번 - Exact Measurement 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 128 MB141343235.955%

문제

Peter is working in a secret chemical laboratory. For his new experiment he needs to measure exactly x nanograms of a secret reagent. He has a balance and several standard masses, and his goal is to choose a set of standard masses with total sum equal to x ng.

Standard masses come in n sealed boxes. The i-th box contains qi identical masses of 10ki ng. Peter wants to open the minimal number of boxes to take a set of masses with the sum of their weights of x ng.

입력

The first line of the input file contains two integer numbers x and n (1 ≤ x ≤ 1018, 1 ≤ n ≤ 105). The next n lines contain pairs of numbers ki and qi (0 ≤ ki ≤ 18, 1 ≤ qi · 10ki ≤ 1018).

출력

On the first line output the minimal number of boxes that should be opened. On the second line output the numbers of these boxes in any order. Boxes are numbered in the order they appear in the input file starting from 1. If it is impossible to measure exactly x ng, output a single line with −1.

제한

예제 입력 1

289 4
2 3
1 5
1 8
0 30

예제 출력 1

3
1 3 4

예제 입력 2

300 4
2 3
1 5
1 7
0 30

예제 출력 2

1
1

예제 입력 3

201 1
2 3

예제 출력 3

-1

힌트

출처

ICPC > Regionals > Northern Eurasia > Northern Eurasia Finals > NEERC 2012 E번

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

출처

대학교 대회

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

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