D. [R6D]数字矩阵

    Type: Default 1000ms 512MiB

[R6D]数字矩阵

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

时空限制

1S/512M

题目描述

给定长度为 nn 的数列 AA 和长度为 mm 的数列 BB,根据这两个数列可以计算得到一个 n×mn\times m 的数字矩阵 C(i,j)=Ai×BjC(i,j)=A_i\times B_j

将数字矩阵 CC 中的 n×mn\times m 个数字从小到大排序,求排序后第 LL 小到第 RR 小的数字之和。

格式

输入格式

第一行包含两个整数 nnmm,分别表示数列 AA 和数列 BB 的长度。

第二行包含 nn 个整数 AiA_i

第三行包含 mm 个整数 BiB_i

第四行包含两个整数 LLRR,含义与题目描述相同。

输出格式

输出一个整数,表示将数字矩阵 CC 排序后第 LL 小到第 RR 小的数字之和。

样例

样例输入 #1

3 2
3 10 2
4 1
2 4

样例输出 #1

21

样例解释 #1

将数字矩阵 CC 排序后结果为 {2,3,8,10,12,40}\{2,3,8,10,12,40\},第 22 小到第 44 小的数字之和为 3+8+10=213+8+10=21

数据规模

对于 100%100\% 的数据,1n,m1051\leq n,m\leq 10^51Ai,Bi2×1041\leq A_i,B_i \leq 2\times 10^41LRn×m1\leq L\leq R\leq n\times m

测试点编号 n,mn,m Ai,BiA_i,B_i 特殊性质
1~2 1000\leq 1000 2×104\leq2 \times 10^4 \text{无}
3~4 105\leq 10^5 2000\leq 2000
5~6 2×104\leq2 \times 10^4 L=1L=1
7~10 \text{无}

代码源挑战赛 Round 6

Not Attended
Status
Done
Rule
DMY
Problem
6
Start at
2025-4-4 20:00
End at
2025-4-4 21:30
Duration
1.5 hour(s)
Host
Partic.
564