結果

問題 No.1359 [Zelkova 3rd Tune] 四人セゾン
ユーザー tentententen
提出日時 2021-01-25 09:16:51
言語 Java21
(openjdk 21)
結果
AC  
実行時間 1,664 ms / 2,000 ms
コード長 1,126 bytes
コンパイル時間 5,201 ms
コンパイル使用メモリ 73,672 KB
実行使用メモリ 55,112 KB
最終ジャッジ日時 2023-09-03 19:18:37
合計ジャッジ時間 114,714 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 103 ms
39,168 KB
testcase_01 AC 103 ms
39,100 KB
testcase_02 AC 118 ms
39,284 KB
testcase_03 AC 1,223 ms
51,648 KB
testcase_04 AC 1,256 ms
51,220 KB
testcase_05 AC 1,212 ms
51,940 KB
testcase_06 AC 1,204 ms
51,792 KB
testcase_07 AC 1,362 ms
51,824 KB
testcase_08 AC 1,294 ms
51,420 KB
testcase_09 AC 802 ms
47,692 KB
testcase_10 AC 798 ms
47,664 KB
testcase_11 AC 1,374 ms
53,056 KB
testcase_12 AC 1,431 ms
55,112 KB
testcase_13 AC 1,322 ms
51,952 KB
testcase_14 AC 1,335 ms
52,016 KB
testcase_15 AC 1,184 ms
50,944 KB
testcase_16 AC 1,181 ms
51,992 KB
testcase_17 AC 1,540 ms
53,020 KB
testcase_18 AC 1,546 ms
53,672 KB
testcase_19 AC 1,411 ms
52,708 KB
testcase_20 AC 1,324 ms
52,764 KB
testcase_21 AC 1,510 ms
53,192 KB
testcase_22 AC 1,435 ms
53,748 KB
testcase_23 AC 1,291 ms
51,548 KB
testcase_24 AC 1,353 ms
52,296 KB
testcase_25 AC 641 ms
46,672 KB
testcase_26 AC 537 ms
47,196 KB
testcase_27 AC 983 ms
50,452 KB
testcase_28 AC 1,080 ms
50,560 KB
testcase_29 AC 1,114 ms
51,460 KB
testcase_30 AC 1,061 ms
51,468 KB
testcase_31 AC 1,189 ms
51,896 KB
testcase_32 AC 1,145 ms
51,464 KB
testcase_33 AC 1,219 ms
51,680 KB
testcase_34 AC 1,095 ms
51,432 KB
testcase_35 AC 1,064 ms
51,660 KB
testcase_36 AC 1,141 ms
51,096 KB
testcase_37 AC 595 ms
46,540 KB
testcase_38 AC 586 ms
46,564 KB
testcase_39 AC 520 ms
46,248 KB
testcase_40 AC 566 ms
46,316 KB
testcase_41 AC 806 ms
47,720 KB
testcase_42 AC 793 ms
46,456 KB
testcase_43 AC 674 ms
47,492 KB
testcase_44 AC 1,580 ms
52,268 KB
testcase_45 AC 1,228 ms
50,844 KB
testcase_46 AC 663 ms
46,436 KB
testcase_47 AC 1,372 ms
51,884 KB
testcase_48 AC 1,451 ms
50,920 KB
testcase_49 AC 1,278 ms
52,456 KB
testcase_50 AC 1,230 ms
50,976 KB
testcase_51 AC 316 ms
45,416 KB
testcase_52 AC 1,582 ms
52,720 KB
testcase_53 AC 1,638 ms
53,516 KB
testcase_54 AC 1,559 ms
52,768 KB
testcase_55 AC 1,578 ms
53,580 KB
testcase_56 AC 1,562 ms
53,376 KB
testcase_57 AC 1,605 ms
52,676 KB
testcase_58 AC 1,612 ms
53,524 KB
testcase_59 AC 1,556 ms
53,504 KB
testcase_60 AC 1,576 ms
53,696 KB
testcase_61 AC 1,568 ms
53,316 KB
testcase_62 AC 1,556 ms
53,748 KB
testcase_63 AC 1,529 ms
53,616 KB
testcase_64 AC 1,579 ms
53,584 KB
testcase_65 AC 1,664 ms
53,972 KB
testcase_66 AC 1,534 ms
53,308 KB
testcase_67 AC 1,608 ms
53,600 KB
testcase_68 AC 1,627 ms
53,124 KB
testcase_69 AC 1,592 ms
53,368 KB
testcase_70 AC 1,540 ms
52,920 KB
testcase_71 AC 1,538 ms
53,336 KB
testcase_72 AC 1,543 ms
53,792 KB
testcase_73 AC 1,583 ms
53,152 KB
testcase_74 AC 1,641 ms
53,536 KB
testcase_75 AC 1,590 ms
53,768 KB
testcase_76 AC 1,649 ms
52,660 KB
testcase_77 AC 1,597 ms
53,056 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int m = sc.nextInt();
        int[][] rates = new int[4][n];
        for (int i = 0; i < 4; i++) {
            for (int j = 0; j < n; j++) {
                rates[i][j] = sc.nextInt();
            }
            Arrays.sort(rates[i]);
        }
        long ans = 0;
        for (int i = 0; i < n; i++) {
            int min = Integer.MAX_VALUE;
            int max = Integer.MIN_VALUE;
            for (int j = 0; j < 4; j++) {
                min = Math.min(min, rates[j][i]);
                max = Math.max(max, rates[j][i]);
            }
            ans += powmod(max - min, k, m);
            ans %= m;
        }
        System.out.println(ans);
    }
    
    static long powmod(long x, long p, int mod) {
        if (p == 0) {
            return 1;
        } else if (p % 2 == 0) {
            return powmod(x * x % mod, p / 2, mod);
        } else {
            return powmod(x, p - 1, mod) * x % mod;
        }
    }
}
0