結果

問題 No.1623 三角形の制作
ユーザー gorugo30gorugo30
提出日時 2021-05-05 22:05:30
言語 Java21
(openjdk 21)
結果
MLE  
実行時間 -
コード長 1,335 bytes
コンパイル時間 2,047 ms
コンパイル使用メモリ 74,008 KB
実行使用メモリ 527,540 KB
最終ジャッジ日時 2023-09-25 20:38:31
合計ジャッジ時間 37,684 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 946 ms
452,280 KB
testcase_01 AC 950 ms
452,512 KB
testcase_02 AC 1,662 ms
454,660 KB
testcase_03 AC 1,631 ms
453,632 KB
testcase_04 AC 1,598 ms
454,328 KB
testcase_05 AC 1,896 ms
462,336 KB
testcase_06 AC 1,539 ms
478,564 KB
testcase_07 AC 1,754 ms
490,168 KB
testcase_08 AC 1,583 ms
502,172 KB
testcase_09 AC 1,575 ms
455,024 KB
testcase_10 AC 1,755 ms
486,776 KB
testcase_11 AC 1,594 ms
455,644 KB
testcase_12 AC 1,608 ms
503,900 KB
testcase_13 AC 1,539 ms
453,892 KB
testcase_14 MLE -
testcase_15 MLE -
testcase_16 AC 1,790 ms
472,112 KB
testcase_17 AC 1,790 ms
454,840 KB
testcase_18 AC 1,841 ms
455,460 KB
testcase_19 AC 1,608 ms
454,976 KB
testcase_20 AC 933 ms
452,244 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

class Main{
    static int max(int x, int y){
        return x > y ? x : y;
    }
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int M = 5000;
        int n = sc.nextInt();
        int Rcnt[] = new int[M + 1];
        int Gcnt[] = new int[M + 1];
        int Bcnt[] = new int[M + 1];
        int x;
        for (int i = 0; i < n; i++){
            x = sc.nextInt();
            Rcnt[x]++;
        }
        for (int i = 0; i < n; i++){
            x = sc.nextInt();
            Gcnt[x]++;
        }
        for (int i = 0; i < n; i++){
            x = sc.nextInt();
            Bcnt[x]++;
        }
        
        long C[][] = new long[M + 2][2 * M + 2];
        for (int i = 1; i <= M; i++){
            for (int j = 1; j <= M; j++){
                C[max(i, j) + 1][i + j + 1] += (long)Gcnt[i] * Bcnt[j];
            }
        }
        for (int i = 0; i < M + 1; i++){
            for (int j = 0; j < 2 * M + 1; j++){
                C[i + 1][j + 1] += C[i][j + 1] + C[i + 1][j] - C[i][j];
            }
        }
        long ans = 0;
        for (int i = 1; i <= M; i++){
            long tmp = C[i + 1][2 * M + 1] + C[1][i + 1] - C[i + 1][i + 1] - C[1][2 * M + 1];
            ans += (long)Rcnt[i] * tmp;
        }

        System.out.println(ans);
    }
}
0