아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Bags

면접 대비

시간 제한1초메모리 제한1024 MB

요약
각 테스트마다 목표 무게와 정확히 일치하도록 아이템을 고를 때 필요한 최소 개수를 구하고, 불가능하면 Not possible을 출력한다.
난이도

보통10점 중 5점

유형
동적 계획법, 배열, 그리디, 정렬
정답자
아직 제출이 없습니다

문제

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

  1. 예제 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
    
    예상 출력
    6
    3
    Not possible