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

13751번 - Barbells 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB19912510160.119%

문제

Your local gym has b bars and p plates for barbells. In order to prepare a weight for lifting, you must choose a single bar, which has two sides. You then load each side with a (possibly empty) set of plates. For safety reasons, the plates on each side must balance; they must sum to the same weight. The combination of plates on either side might be different, but the total weight on either side must be the same. What weights are available for lifting?

입력

Each input will consist of a single test case. Note that your program may be run multiple times on different inputs. The first line of input contains two integers, b and p (1 ≤ b,p ≤ 14), representing the number of bars and plates. Then, there are b lines each containing a single integer x (1 ≤ x ≤ 108 ) which are the weights of the bars. After that, there are p lines each containing a single integer y (1 ≤ y ≤ 108 ) which are the weights of the plates.

출력

Output a sorted list of all possible lifting weights, one per line. There must be no duplicates.

제한

예제 입력 1

2 5
100
110
5
5
1
4
6

예제 출력 1

100
110
112
120
122
130

힌트

출처

ICPC > Regionals > North America > Southeast USA Regional > 2016 Southeast USA Regional Programming Contest > Division 2 A번

ICPC > Regionals > North America > Pacific Northwest Regional > 2016 Pacific Northwest Region Programming Contest > Division 2 N번

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

출처

대학교 대회

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

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