小扣在秋日市集选择了一家早餐摊位,一维整型数组 staple 中记录了每种主食的价格,一维整型数组 drinks 中记录了每种饮料的价格。小扣的计划选择一份主食和一款饮料,且花费不超过 x 元。请返回小扣共有多少种购买方案。
注意:答案需要以 1e9 + 7 (1000000007) 为底取模,如:计算初始结果为:1000000008,请返回 1
第一行包含三个整数 n、m、x,分别表示主食种类数、饮料种类数和预算上限。
第二行包含 n 个整数,表示每种主食的价格。
第三行包含 m 个整数,表示每种饮料的价格。
输出一个整数,表示满足条件的购买方案数对 1e9 + 7 取模的结果。
3 3 15 10 20 5 5 5 2
6
3 4 9 2 1 1 8 9 5 1
8
1 <= staple.length <= 10^81 <= drinks.length <= 10^81 <= staple[i], drinks[i] <= 10^51 <= x <= 2 * 10^5
小扣有 6 种购买方案
第 1 种方案:staple[0] + drinks[0] = 10 + 5 = 15
staple[0] + drinks[1] = 10 + 5 = 15staple[0] + drinks[2] = 10 + 2 = 12staple[2] + drinks[0] = 5 + 5 = 10staple[2] + drinks[1] = 5 + 5 = 10第 6 种方案:staple[2] + drinks[2] = 5 + 2 = 7
小扣有 8 种购买方案,所选主食与所选饮料在数组中对应的下标分别是:
第 1 种方案:staple[0] + drinks[2] = 2 + 5 = 7
staple[0] + drinks[3] = 2 + 1 = 3staple[1] + drinks[0] = 1 + 8 = 9staple[1] + drinks[2] = 1 + 5 = 6staple[1] + drinks[3] = 1 + 1 = 2staple[2] + drinks[0] = 1 + 8 = 9staple[2] + drinks[2] = 1 + 5 = 6staple[2] + drinks[3] = 1 + 1 = 2leetcode