题目描述
给定三个整数数组
![](https://i-blog.csdnimg.cn/blog_migrate/f945e3126e41e478dc342f867aa66405.png)
![](https://i-blog.csdnimg.cn/blog_migrate/e312015f6a8ecbe99fd2539dc4c9d0ad.png)
输入描述
![](https://i-blog.csdnimg.cn/blog_migrate/853acfc8bd11f1c02d2665fcea372aff.png)
输出描述
输出一个整数表示答案。
输入输出样例
示例
输入
3
1 1 1
2 2 2
3 3 3
输出
27
运行限制
最大运行时间:2s
最大运行内存: 256M
源码:
import java.util.Arrays;
import java.util.Scanner;
public class 递增三元组 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n=scanner.nextInt();
int a[] = new int[n+1];
int b[] = new int[n+1];
int c[] = new int[n+1];
for (int i = 1; i < c.length; i++) {
a[i] = scanner.nextInt();
}
for (int i = 1; i < c.length; i++) {
b[i] = scanner.nextInt();
}
for (int i = 1; i < c.length; i++) {
c[i] = scanner.nextInt();
}
int i=1,k=1;
long ans=0;
Arrays.sort(a);
Arrays.sort(b);
Arrays.sort(c);
for (int j = 1; j <= n; j++) {
while(i<=n && a[i]<b[j]) i++;
while(k<=n && c[k]<=b[j]) k++;
ans+=(long)(i-1)*(n-k+1);
}
System.out.println(ans);
}
}