#CCBCHMOT0000048. Lần đầu trung bình vượt mốc (First Prefix Average Above Threshold)
Lần đầu trung bình vượt mốc (First Prefix Average Above Threshold)
First Prefix Average Above Threshold
Source: Phước Hưng OJ
Version: Phuoc Hung OJ Extended
Problem Statement
Given n integers and integer threshold T, find the smallest one-based position i whose prefix average is strictly greater than T, or -1 if none exists.
Input
The first line contains n and T. The next line has exactly n integers in order.
Output
Print the first one-based position, or -1.
Subtasks
- Subtask 1 (20%): 1≤n≤10, |T|≤10, |a_i|≤10.
- Subtask 2 (30%): 1≤n≤1000, |T|≤1000, |a_i|≤1000.
- Subtask 3 (50%): 1≤n≤100000, |T|≤1000000, |a_i|≤10000.
Examples
Example 1
Input
4 3
1 2 9 0
Output
3
Explanation
Prefix sums are 1,3,12; the first average above three occurs at i=3.
Example 2
Input
3 5
5 5 5
Output
-1
Explanation
All prefix averages equal five, not strictly above it.