#B3899. Reservoir Dam Break Risk
Reservoir Dam Break Risk
Reservoir Dam Break Risk
A reservoir is operating under high load due to continuous heavy rains. Its water level has exceeded the safe limit, putting it at the verge of a dam break.
Aya is responsible for controlling the reservoir's water level. Based on forecasts from both the meteorological and hydrological departments, she receives the inflow amounts \(a_1, a_2, \dots, a_n\) and the outflow amounts \(b_1, b_2, \dots, b_n\) for the next \(n\) hours. The net inflow for the \(i\)-th hour is defined as:
\(a_i - b_i\)
She believes that if there exists any continuous period of \(k\) hours during which the sum of net inflows is greater than or equal to a threshold \(M\), then there is a possibility of a dam break, which could lead to dangerous flooding downstream.
Your task is to determine whether such a period exists.
inputFormat
The input consists of three lines:
- The first line contains three integers \(n\), \(k\), and \(M\) separated by spaces.
- The second line contains \(n\) integers representing the inflow amounts \(a_1, a_2, \dots, a_n\).
- The third line contains \(n\) integers representing the outflow amounts \(b_1, b_2, \dots, b_n\).
outputFormat
Print a single line: Yes if there exists any continuous segment of \(k\) hours for which the sum of net inflows is at least \(M\); otherwise, print No.
sample
5 2 7
6 5 2 4 1
1 2 1 1 0
Yes