#CCBOTPBA0000028. Mốc đạt doanh thu (First Revenue Milestone)
Mốc đạt doanh thu (First Revenue Milestone)
First Revenue Milestone
Source: Phước Hưng OJ
Version: Phuoc Hung OJ Extended
Problem Statement
Given n nonnegative revenues in order, print the first number of rounds whose cumulative sum reaches T. T=0 yields zero; print -1 if the threshold is never reached.
Input
Integers n T, followed by exactly n nonnegative revenues.
Output
The first round count 0..n, or -1.
Subtasks
-
Subtask 1 (20%):
n ≤ 10,T ≤ 100, revenues0..100. -
Subtask 2 (30%):
n ≤ 1000,T ≤ 10^6, revenues0..10^6. -
Subtask 3 (50%):
n ≤ 100000,T ≤ 10^14, revenues0..10^9.
Examples
Example 1
Input:
4 8
2 3 3 10
Output:
3
Explanation: Cumulative revenue first reaches eight at round three.
Example 2
Input:
2 0
0 0
Output:
0
Explanation: The zero threshold is met before any round.
Example 3
Input:
2 9
4 4
Output:
-1
Explanation: Total revenue eight is below nine.