参考代码:
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; public class Main { public static void main(String[] args) throws IOException { BufferedReader read = new BufferedReader(new InputStreamReader(System.in));//java数据较多时用这个输入,我还不太熟悉,可能写的不行 int n = Integer.parseInt(read.readLine().split(" ")[0]); int[] a = new int[n]; int[] b = new int[n]; int[] c = new int[n]; String[] in1 = read.readLine().split(" "); for(int i = 0; i < n; i++) a[i] = Integer.parseInt(in1[i]); String[] in2 = read.readLine().split(" "); for(int i = 0; i < n; i++) b[i] = Integer.parseInt(in2[i]); String[] in3 = read.readLine().split(" "); for(int i = 0; i < n; i++) c[i] = Integer.parseInt(in3[i]); Arrays.sort(a); Arrays.sort(b); Arrays.sort(c); long res = 0; int p = 0; int q = 0; for(int i = 0; i < n; i++)//枚举b数组的值 { while(p < n && a[p] < b[i]) p++; while(q < n && c[q] <= b[i]) q++; res += (long)p * (n - q); } System.out.print(res); } }
0.0分
5 人评分
C语言程序设计教程(第三版)课后习题6.5 (C语言代码)浏览:748 |
母牛的故事 (C语言代码)浏览:478 |
C语言训练-斐波纳契数列 (C语言代码)浏览:593 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:483 |
C语言程序设计教程(第三版)课后习题5.5 (C语言代码)浏览:426 |
自编的贪吃蛇小游戏,代码装上easyx图形库就能运行。浏览:941 |
WU-C语言程序设计教程(第三版)课后习题12.5 (C++代码)浏览:954 |
文件操作浏览:655 |
小九九 (C语言代码)浏览:647 |
C语言程序设计教程(第三版)课后习题6.4 (C语言代码)浏览:1036 |