DSTJZ


私信TA

用户名:dotcpp0721777

访问量:4443

签 名:

天下难事,必作于易;天下大事,必作于细。

等  级
排  名 50
经  验 10992
参赛次数 13
文章发表 312
年  龄 18
在职情况 学生
学  校 狗熊岭23届毕业生
专  业

  自我简介:

TA的其他文章


参考代码:

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 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区