#abc282h. Ex - Min + Sum
Ex - Min + Sum
Score : points
问题描述
你有两个长度为 的整数序列: 和 。
输出满足以下条件的整数对 的数量,其中 。
- $\min\lbrace A_l, A_{l+1}, \ldots, A_r \rbrace + (B_l + B_{l+1} + \cdots + B_r) \leq S$
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
You are given two sequences of integers of length : and .
Print the number of pairs of integers that satisfy and the following condition.
- $\min\lbrace A_l, A_{l+1}, \ldots, A_r \rbrace + (B_l + B_{l+1} + \cdots + B_r) \leq S$
Constraints
- All values in the input are integers.
Input
The input is given from Standard Input in the following format:
Output
Print the answer.
Sample Input 1
4 15
9 2 6 5
3 5 8 9
Sample Output 1
6
The following six pairs of integers satisfy and the condition in the problem statement: , , , , , and .
Sample Input 2
15 100
39 9 36 94 40 26 12 26 28 66 73 85 62 5 20
0 0 7 7 0 5 5 0 7 9 9 4 2 5 2
Sample Output 2
119
update @ 2024/3/10 11:51:19