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

31325번 - Devil's Hell deLivery 스페셜 저지다국어

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

문제

Devil's Hell deLivery company delivers literally everything: boxes, packages, packets, datagrams et cetera.

The delivery process from city A to city B works as follows. There are $N$ trucks and $K$ items. The capacity of truck number $i$ equals $c_i$. The weight of item number $j$ equals $w_j$. The trucks make one or more delivery steps.

During one step, some items are loaded into some trucks. Items can not be split. Each truck's capacity must not be exceeded by the total weight of the items assigned to it. All trucks depart simultaneously.

At the end of each step, all trucks come back to the place where they started. If there are any items left, another step is performed.

Your task is to distribute items among steps and trucks so that the number of steps is minimized.

입력

The input contains up to a hundred test cases.

Each test case starts with a single line containing two integers $N$ and $K$ (1ドル \le N \le 5,ドル 1ドル \le K \le 9$): the number of trucks and the number of items, respectively. The following line consists of $N$ integers $c_1, \ldots, c_N$ (1ドル \le c_i \le 10^8$): the capacities of the trucks. The following line consists of $K$ integers $w_1, \ldots, w_K$ (1ドル \le w_i \le 10^8$): the weights of the items.

출력

For each test case, if the delivery is impossible, write a single line with a single integer $-1$.

Otherwise, start with a line containing a single integer $S$: the number of steps required. This number must be minimized. After that, write $S$ lines describing the steps. Each step description must start with an integer $I_i,ドル the number of items delivered during the step. This number must be followed by $I_i$ pairs $a_j$ $b_j$. Each pair $a_j$ $b_j$ means that the item $a_j$ is assigned to the truck $b_j$.

If there is more than one possible optimal answer, write any one of them.

제한

예제 입력 1

2 4
10 20
5 5 5 5
2 1
10 10
20

예제 출력 1

1
4 1 1 2 1 3 2 4 2
-1

힌트

출처

Contest > Open Cup > 2014/2015 Season > Stage 5: Grand Prix of Peterhof A번

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

출처

대학교 대회

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

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