#K7671. Escape Room Success Count

    ID: 34703 Type: Default 1000ms 256MiB

Escape Room Success Count

Escape Room Success Count

You are given several scenarios representing escape room challenges. In each scenario, a team records a sequence of steps while attempting to escape a room. The challenge comes with a threshold value. The team is considered to have successfully completed the escape room if the sum of the recorded steps is less than or equal to the threshold.

Mathematically, for a given test case, if the list of steps is \(s_1, s_2, \dots, s_n\) and the threshold is \(T\), the team is successful if:

[ \sum_{i=1}^{n} s_i \leq T ]

You will be given multiple test cases. For each test case, output 1 if the team successfully escapes (i.e., the condition above holds), or 0 otherwise. Input and output must be handled via stdin and stdout.

inputFormat

The first line of the input contains an integer \(k\) representing the number of test cases. Each test case consists of three lines:

  • The first line contains an integer \(n\), which is the number of steps recorded.
  • The second line contains \(n\) space-separated integers representing the number of steps.
  • The third line contains an integer \(T\), the threshold value.

outputFormat

For each test case, output a single line containing 1 if the sum of steps is less than or equal to \(T\), otherwise output 0.

## sample
1
5
10 20 30 40 50
150
1

</p>