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

26556번 - Bags 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 1024 MB64514180.392%

문제

When creating a gift bag, you are trying to create a bag that weighs as much as possible with as few items as possible. This is to make it feel like the guests are receiving a lot without having to use as many items in each gift bag. Instead of finding how much to put in each gift bag, write a program that finds the fewest number of items you can put into a gift bag to reach the recommended value.

입력

The first line will contain a single integer n that indicates the number of data sets that follow. Each data set will be three lines, and will start with a single integer x denoting the number of items. The next line will contain x integers, indicating the weight of each item. The next line will be a single integer indicating the total weight you are trying to reach.

출력

Output the smallest number of items that will add up to the weight to be returned. If it is not possible to add up exactly to the weight to be returned, print Not possible.

제한

예제 입력 1

3
10
1 3 3 3 5 7 7 5 5 10
39
10
1 2 3 4 5 6 7 8 9 10
27
1
100
50

예제 출력 1

6
3
Not possible

힌트

출처

School > PLU High School Programming Contest > PLU 2018 > Advanced 10번

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

출처

대학교 대회

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

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