)
样例输入3 5 20 25 30 35 40 10 20 25 35 30 40样例输出1 3 3运行限制语言最大运行时间最大运行内存C1s256MC1s256MJava2s256MPython33s256MPyPy33s256MGo3s256MJavaScript3s256M题解:import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan new Scanner(System.in); int N scan.nextInt(); int M scan.nextInt(); int[] arr new int[M]; int[][] dp new int[N][2]; for (int i 0; i M; i) { arr[i] scan.nextInt(); } for (int i 0; i N; i) { dp[i][0] scan.nextInt(); dp[i][1] scan.nextInt(); } for (int i 0; i N; i) { int count 0; for (int j 0; j M; j) { if(dp[i][0] arr[j] arr[j] dp[i][1]){ count; } } System.out.println(count); } scan.close(); } }解题思路:这题不难,但我感觉挺有意思的一道模拟题,读取蜜茶数量 N、保温杯数量 M保存所有保温杯温度和每种蜜茶的温度区间。 双重循环遍历每一款蜜茶逐个检查保温杯温度是否落在该蜜茶的区间内统计符合条件的数量并输出。 数据范围很小直接暴力枚举即可简单不易出错。补充:优化拓展如果 N、M 很大的时候可以先把温度数组排序然后二分查找左右边界但是本题数据范围很小暴力写最简单比赛的时候优先选择不容易出错的写法。