Min + Sum

 2 Sec 256 MB |  Markdown 获取标签

 

题目描述

You are given two sequences of integers of length NN: A=(A1,A2,,AN)A = (A_1, A_2, \ldots, A_N) and B=(B1,B2,,BN)B = (B_1, B_2, \ldots, B_N).

Print the number of pairs of integers (l,r)(l, r) that satisfy 1lrN1 \leq l \leq r \leq N and the following condition.

  • min{Al,Al+1,,Ar}+(Bl+Bl+1++Br)S\min\lbrace A_l, A_{l+1}, \ldots, A_r \rbrace + (B_l + B_{l+1} + \cdots + B_r) \leq S

Constraints

  • 1N2×1051 \leq N \leq 2 \times 10^5
  • 0S3×10140 \leq S \leq 3 \times 10^{14}
  • 0Ai10140 \leq A_i \leq 10^{14}
  • 0Bi1090 \leq B_i \leq 10^9
  • All values in the input are integers.

输入格式

The input is given from Standard Input in the following format:

NN SS
A1A_1 A2A_2 \ldots ANA_N
B1B_1 B2B_2 \ldots BNB_N

输出格式

Print the answer.

样例输入 #1

4 15
9 2 6 5
3 5 8 9

样例输出 #1

6

样例输入 #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

样例输出 #2

119

 

 您尚未登录,无法进行代码提交

2024 秋季 个人排位赛(六)

2024-07-16 12:00
2024-07-16 17:00
Ended