CF1614A Divan and a Store

题目描述

给定一个长为 $n$ 的数组 $a$,从中选出若干个在 $[l,r]$ 区间的数,使得总和不大于 $k$。求最多个数。

输入格式

第一行一个 $t$,表示数据组数。 每一组数据中: 第一行有四个整数 $ n $ , $ l $ , $ r $ , $ k $ ( $ 1 \le n \le 100 $ , $ 1 \le l \le r \le 10^9 $ , $ 1 \le k \le 10^9 $ )。 第二行有 $n$ 个整数,表示数组 $a$。

输出格式

对于每一组数据输出一行一个整数,表示最大个数。

说明/提示

In the first example Divan can buy chocolate bars $ 1 $ and $ 3 $ and spend $ 100 $ dollars on them. In the second example Divan can buy chocolate bars $ 3 $ and $ 4 $ and spend $ 7 $ dollars on them. In the third example Divan can buy chocolate bars $ 3 $ , $ 4 $ , and $ 5 $ for $ 12 $ dollars. In the fourth example Divan cannot buy any chocolate bar because each of them is either too cheap or too expensive. In the fifth example Divan cannot buy any chocolate bar because he considers the first bar too cheap, and has no budget for the second or third. In the sixth example Divan can buy all the chocolate bars in the shop.