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

19418번 - Dreamoon and NightMarket 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 512 MB444100.000%

문제

After moving to Taipei, Dreamoon always goes to dinner at Jinmei Night Market. There are $N$ kinds of food sold at Jinmei Night Market. These foods are numbered from 1ドル$ to $N$. The price of one piece of $i$-th food is $p_i$.

Every night, Dreamoon will choose a non-empty set of foods and eat one piece of each food in this set. Dreamoon likes new things. So he won't choose the same set in two different nights. Besides this, because Dreamoon is a poor boy, each night, he will choose the cheapest food set that he didn't choose before.

Now, you are given a positive integer $K$. Can you tell Dreamoon which set of foods he will choose on $K$-th day? You only have to tell him how much he will spent on this day.

입력

The input consists of two lines. The first line contains an integer $N$. The second line consists of $N$ integers $p_1, p_2, \ldots, p_N$.

출력

Output one number indicating how much Dreamoon will spend on food on $K$-th day.

제한

  • 2ドル \le N \le 2 \times 10^5$
  • 1ドル \le K \le \min(10^6, 2^N - 1)$
  • 1ドル \le p_i \le 10^8$

예제 입력 1

5 30
4 2 1 16 8

예제 출력 1

30

예제 입력 2

4 5
1 1 2 2

예제 출력 2

2

힌트

출처

Camp > Petrozavodsk Programming Camp > Winter 2017 > Day 7: National Taiwan U Contest G번

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

출처

대학교 대회

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

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