luogu#P4799. [CEOI 2015] 世界冰球锦标赛 (Day2)

    ID: 3825 远端评测题 1000ms 500MiB 尝试: 1 已通过: 1 难度: 6 上传者: 标签>搜索2015CEOI(中欧)折半搜索 meet in the middle

[CEOI 2015] 世界冰球锦标赛 (Day2)

Problem Description

Translated from CEOI2015 Day2 T1 “Ice Hockey World Championship”.

This year’s Ice Hockey World Championship is held in the Czech Republic. Bobek has arrived in Prague. He is not a fan of any team, and he has no sense of time. He simply wants to watch some matches. If he had enough money, he would watch all the matches. Unfortunately, his money is very limited, so he decides to spend all his money on tickets.

Given Bobek’s budget and the ticket price of each match, find: how many different ways he can choose matches to watch such that the total ticket cost does not exceed the budget. If there exists a match that is watched in one plan but not watched in another plan, then the two plans are considered different.

Input Format

The first line contains two positive integers NN and M(1N40,1M1018)M(1 \leq N \leq 40,1 \leq M \leq 10^{18}), denoting the number of matches and Bobek’s extremely limited budget.

The second line contains NN positive integers separated by spaces, each not exceeding 101610^{16}, representing the ticket price of each match.

Output Format

Output one line containing the number of plans. Since NN is very large, note that the answer 240\le 2^{40}.

5 1000
100 1500 500 500 1000
8

Hint

Sample Explanation

The eight plans are:

  • Watch no matches and leave.
  • The match with price 100100.
  • The first match with price 500500.
  • The second match with price 500500.
  • The match with price 100100 and the first match with price 500500.
  • The match with price 100100 and the second match with price 500500.
  • Both matches with price 500500.
  • The match with price 10001000.

There are 10 test groups. For each group you pass, you get 10 points. The Constraints for each group are shown in the table below:

Test group 121-2 343-4 575-7 8108-10
NN \leq 1010 2020 4040
MM \leq 10610^6 101810^{18} 10610^6 101810^{18}

Translated by ChatGPT 5