結果

問題 No.1359 [Zelkova 3rd Tune] 四人セゾン
ユーザー tentententen
提出日時 2023-04-17 09:16:12
言語 Java21
(openjdk 21)
結果
AC  
実行時間 969 ms / 2,000 ms
コード長 2,392 bytes
コンパイル時間 3,358 ms
コンパイル使用メモリ 90,804 KB
実行使用メモリ 66,364 KB
最終ジャッジ日時 2024-04-20 15:55:46
合計ジャッジ時間 63,564 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 47 ms
36,920 KB
testcase_01 AC 47 ms
37,024 KB
testcase_02 AC 49 ms
37,492 KB
testcase_03 AC 668 ms
54,972 KB
testcase_04 AC 708 ms
55,380 KB
testcase_05 AC 617 ms
55,112 KB
testcase_06 AC 588 ms
54,732 KB
testcase_07 AC 707 ms
57,772 KB
testcase_08 AC 715 ms
57,600 KB
testcase_09 AC 387 ms
46,364 KB
testcase_10 AC 416 ms
46,120 KB
testcase_11 AC 741 ms
61,324 KB
testcase_12 AC 851 ms
61,248 KB
testcase_13 AC 672 ms
55,724 KB
testcase_14 AC 723 ms
55,716 KB
testcase_15 AC 666 ms
55,972 KB
testcase_16 AC 630 ms
55,952 KB
testcase_17 AC 815 ms
63,964 KB
testcase_18 AC 912 ms
64,572 KB
testcase_19 AC 767 ms
55,948 KB
testcase_20 AC 750 ms
55,940 KB
testcase_21 AC 832 ms
61,368 KB
testcase_22 AC 804 ms
60,516 KB
testcase_23 AC 672 ms
55,596 KB
testcase_24 AC 754 ms
55,440 KB
testcase_25 AC 284 ms
45,068 KB
testcase_26 AC 267 ms
45,232 KB
testcase_27 AC 509 ms
51,804 KB
testcase_28 AC 532 ms
53,512 KB
testcase_29 AC 557 ms
55,436 KB
testcase_30 AC 576 ms
53,336 KB
testcase_31 AC 683 ms
55,700 KB
testcase_32 AC 669 ms
55,992 KB
testcase_33 AC 578 ms
53,352 KB
testcase_34 AC 601 ms
53,312 KB
testcase_35 AC 636 ms
55,840 KB
testcase_36 AC 602 ms
55,728 KB
testcase_37 AC 273 ms
45,036 KB
testcase_38 AC 278 ms
45,700 KB
testcase_39 AC 253 ms
45,212 KB
testcase_40 AC 264 ms
45,036 KB
testcase_41 AC 395 ms
46,424 KB
testcase_42 AC 376 ms
46,436 KB
testcase_43 AC 331 ms
46,840 KB
testcase_44 AC 881 ms
61,480 KB
testcase_45 AC 608 ms
55,864 KB
testcase_46 AC 355 ms
46,140 KB
testcase_47 AC 706 ms
55,508 KB
testcase_48 AC 699 ms
56,116 KB
testcase_49 AC 726 ms
55,880 KB
testcase_50 AC 669 ms
56,052 KB
testcase_51 AC 141 ms
41,124 KB
testcase_52 AC 843 ms
61,912 KB
testcase_53 AC 876 ms
63,924 KB
testcase_54 AC 810 ms
65,384 KB
testcase_55 AC 865 ms
65,116 KB
testcase_56 AC 862 ms
64,996 KB
testcase_57 AC 883 ms
65,480 KB
testcase_58 AC 811 ms
65,476 KB
testcase_59 AC 861 ms
65,372 KB
testcase_60 AC 893 ms
64,352 KB
testcase_61 AC 919 ms
61,296 KB
testcase_62 AC 913 ms
65,756 KB
testcase_63 AC 930 ms
65,012 KB
testcase_64 AC 908 ms
60,428 KB
testcase_65 AC 912 ms
64,832 KB
testcase_66 AC 916 ms
66,364 KB
testcase_67 AC 875 ms
65,392 KB
testcase_68 AC 868 ms
65,088 KB
testcase_69 AC 865 ms
65,276 KB
testcase_70 AC 810 ms
65,048 KB
testcase_71 AC 930 ms
66,352 KB
testcase_72 AC 969 ms
65,456 KB
testcase_73 AC 866 ms
65,068 KB
testcase_74 AC 850 ms
65,136 KB
testcase_75 AC 892 ms
65,484 KB
testcase_76 AC 937 ms
64,560 KB
testcase_77 AC 966 ms
65,068 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Main {
    static int mod;
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int n = sc.nextInt();
        int k = sc.nextInt();
        mod = sc.nextInt();
        int[][] values = new int[4][n];
        for (int i = 0; i < 4; i++) {
            for (int j = 0; j < n; j++) {
                values[i][j] = sc.nextInt();
            }
            Arrays.sort(values[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, values[j][i]);
                max = Math.max(max, values[j][i]);
            }
            ans += pow(max - min, k);
            ans %= mod;
        }
        System.out.println(ans);
    }
    
    static long pow(long x, int p) {
        if (p == 0) {
            return 1;
        } else if (p % 2 == 0) {
            return pow(x * x % mod, p / 2);
        } else {
            return pow(x, p - 1) * x % mod;
        }
    }
}
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