結果
問題 | No.1359 [Zelkova 3rd Tune] 四人セゾン |
ユーザー | tenten |
提出日時 | 2023-04-17 09:16:12 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 1,124 ms / 2,000 ms |
コード長 | 2,392 bytes |
コンパイル時間 | 4,072 ms |
コンパイル使用メモリ | 84,984 KB |
実行使用メモリ | 65,640 KB |
最終ジャッジ日時 | 2024-10-12 11:38:51 |
合計ジャッジ時間 | 73,185 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 52 ms
37,308 KB |
testcase_01 | AC | 52 ms
37,456 KB |
testcase_02 | AC | 52 ms
37,228 KB |
testcase_03 | AC | 722 ms
54,992 KB |
testcase_04 | AC | 736 ms
55,572 KB |
testcase_05 | AC | 704 ms
54,304 KB |
testcase_06 | AC | 747 ms
54,696 KB |
testcase_07 | AC | 814 ms
57,524 KB |
testcase_08 | AC | 877 ms
57,268 KB |
testcase_09 | AC | 440 ms
46,232 KB |
testcase_10 | AC | 458 ms
46,316 KB |
testcase_11 | AC | 818 ms
61,400 KB |
testcase_12 | AC | 930 ms
61,604 KB |
testcase_13 | AC | 793 ms
55,572 KB |
testcase_14 | AC | 690 ms
55,712 KB |
testcase_15 | AC | 758 ms
56,560 KB |
testcase_16 | AC | 705 ms
56,172 KB |
testcase_17 | AC | 897 ms
64,372 KB |
testcase_18 | AC | 891 ms
64,272 KB |
testcase_19 | AC | 888 ms
55,828 KB |
testcase_20 | AC | 930 ms
56,148 KB |
testcase_21 | AC | 919 ms
61,100 KB |
testcase_22 | AC | 897 ms
60,784 KB |
testcase_23 | AC | 707 ms
55,436 KB |
testcase_24 | AC | 733 ms
55,556 KB |
testcase_25 | AC | 291 ms
44,592 KB |
testcase_26 | AC | 290 ms
45,244 KB |
testcase_27 | AC | 530 ms
52,696 KB |
testcase_28 | AC | 572 ms
52,744 KB |
testcase_29 | AC | 608 ms
56,416 KB |
testcase_30 | AC | 612 ms
52,800 KB |
testcase_31 | AC | 796 ms
55,728 KB |
testcase_32 | AC | 726 ms
55,992 KB |
testcase_33 | AC | 643 ms
53,724 KB |
testcase_34 | AC | 652 ms
56,152 KB |
testcase_35 | AC | 700 ms
55,780 KB |
testcase_36 | AC | 783 ms
57,512 KB |
testcase_37 | AC | 331 ms
46,116 KB |
testcase_38 | AC | 307 ms
45,564 KB |
testcase_39 | AC | 257 ms
45,068 KB |
testcase_40 | AC | 262 ms
44,584 KB |
testcase_41 | AC | 385 ms
47,904 KB |
testcase_42 | AC | 414 ms
46,376 KB |
testcase_43 | AC | 362 ms
47,360 KB |
testcase_44 | AC | 878 ms
61,800 KB |
testcase_45 | AC | 695 ms
56,560 KB |
testcase_46 | AC | 376 ms
46,184 KB |
testcase_47 | AC | 807 ms
55,740 KB |
testcase_48 | AC | 721 ms
56,692 KB |
testcase_49 | AC | 714 ms
55,832 KB |
testcase_50 | AC | 724 ms
55,920 KB |
testcase_51 | AC | 151 ms
41,500 KB |
testcase_52 | AC | 835 ms
61,900 KB |
testcase_53 | AC | 939 ms
64,276 KB |
testcase_54 | AC | 979 ms
64,676 KB |
testcase_55 | AC | 925 ms
65,436 KB |
testcase_56 | AC | 966 ms
65,452 KB |
testcase_57 | AC | 950 ms
65,112 KB |
testcase_58 | AC | 1,033 ms
64,696 KB |
testcase_59 | AC | 894 ms
64,968 KB |
testcase_60 | AC | 898 ms
65,004 KB |
testcase_61 | AC | 948 ms
65,352 KB |
testcase_62 | AC | 1,008 ms
65,264 KB |
testcase_63 | AC | 974 ms
64,816 KB |
testcase_64 | AC | 904 ms
61,400 KB |
testcase_65 | AC | 1,005 ms
65,080 KB |
testcase_66 | AC | 950 ms
65,364 KB |
testcase_67 | AC | 1,070 ms
65,040 KB |
testcase_68 | AC | 1,081 ms
65,240 KB |
testcase_69 | AC | 905 ms
65,320 KB |
testcase_70 | AC | 850 ms
65,148 KB |
testcase_71 | AC | 972 ms
65,388 KB |
testcase_72 | AC | 936 ms
64,960 KB |
testcase_73 | AC | 1,124 ms
65,376 KB |
testcase_74 | AC | 951 ms
65,640 KB |
testcase_75 | AC | 1,064 ms
65,136 KB |
testcase_76 | AC | 1,005 ms
64,448 KB |
testcase_77 | AC | 893 ms
64,728 KB |
ソースコード
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(); } }