結果

問題 No.1623 三角形の制作
ユーザー tentententen
提出日時 2023-02-21 15:18:59
言語 Java21
(openjdk 21)
結果
AC  
実行時間 632 ms / 2,000 ms
コード長 2,187 bytes
コンパイル時間 2,764 ms
コンパイル使用メモリ 86,908 KB
実行使用メモリ 68,496 KB
最終ジャッジ日時 2023-09-29 07:50:51
合計ジャッジ時間 13,250 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 83 ms
51,820 KB
testcase_01 AC 86 ms
52,080 KB
testcase_02 AC 411 ms
57,132 KB
testcase_03 AC 438 ms
59,804 KB
testcase_04 AC 428 ms
57,328 KB
testcase_05 AC 586 ms
66,640 KB
testcase_06 AC 242 ms
57,084 KB
testcase_07 AC 437 ms
57,368 KB
testcase_08 AC 241 ms
56,984 KB
testcase_09 AC 409 ms
59,656 KB
testcase_10 AC 402 ms
59,588 KB
testcase_11 AC 436 ms
57,356 KB
testcase_12 AC 304 ms
56,988 KB
testcase_13 AC 404 ms
59,200 KB
testcase_14 AC 314 ms
57,156 KB
testcase_15 AC 425 ms
58,656 KB
testcase_16 AC 424 ms
58,576 KB
testcase_17 AC 480 ms
59,252 KB
testcase_18 AC 632 ms
68,496 KB
testcase_19 AC 353 ms
57,252 KB
testcase_20 AC 85 ms
51,688 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;
import java.util.stream.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int n = sc.nextInt();
        long[] countA = new long[3001];
        for (int i = 0; i < n; i++) {
            countA[sc.nextInt()]++;;
        }
        int[] countB = new int[3001];
        for (int i = 0; i < n; i++) {
            countB[sc.nextInt()]++;;
        }
        int[] countC = new int[3001];
        for (int i = 0; i < n; i++) {
            countC[sc.nextInt()]++;;
        }
        for (int i = 1; i <= 3000; i++) {
            countA[i] += countA[i - 1];
        }
        long ans = 0;
        for (int i = 1; i <= 3000; i++) {
            for (int j = 1; j <= 3000; j++) {
                ans += (countA[Math.min(i + j - 1, 3000)] - countA[Math.max(i, j) - 1]) * countB[i] * countC[j];
            }
        }
        System.out.println(ans);
    }
}
class Utilities {
    static String arrayToLineString(Object[] arr) {
        return Arrays.stream(arr).map(x -> x.toString()).collect(Collectors.joining("\n"));
    }
    
    static String arrayToLineString(int[] arr) {
        return String.join("\n", Arrays.stream(arr).mapToObj(String::valueOf).toArray(String[]::new));
    }
}
class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    StringBuilder sb = new StringBuilder();
    
    public Scanner() throws Exception {
        
    }
    
    public int nextInt() throws Exception {
        return Integer.parseInt(next());
    }
    
    public long nextLong() throws Exception {
        return Long.parseLong(next());
    }
    
    public double nextDouble() throws Exception {
        return Double.parseDouble(next());
    }
    
    public int[] nextIntArray() throws Exception {
        return Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
    }
    
    public String next() throws Exception {
        while (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
    
}
0