結果

問題 No.1359 [Zelkova 3rd Tune] 四人セゾン
ユーザー 小野寺健小野寺健
提出日時 2021-05-26 21:13:32
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,497 bytes
コンパイル時間 4,656 ms
コンパイル使用メモリ 79,780 KB
実行使用メモリ 82,656 KB
最終ジャッジ日時 2024-04-23 14:58:38
合計ジャッジ時間 152,341 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 TLE -
testcase_09 WA -
testcase_10 WA -
testcase_11 TLE -
testcase_12 TLE -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 TLE -
testcase_18 TLE -
testcase_19 TLE -
testcase_20 TLE -
testcase_21 TLE -
testcase_22 TLE -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 TLE -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 TLE -
testcase_49 WA -
testcase_50 WA -
testcase_51 WA -
testcase_52 TLE -
testcase_53 TLE -
testcase_54 TLE -
testcase_55 TLE -
testcase_56 TLE -
testcase_57 TLE -
testcase_58 TLE -
testcase_59 TLE -
testcase_60 TLE -
testcase_61 TLE -
testcase_62 TLE -
testcase_63 TLE -
testcase_64 TLE -
testcase_65 TLE -
testcase_66 TLE -
testcase_67 TLE -
testcase_68 TLE -
testcase_69 TLE -
testcase_70 TLE -
testcase_71 TLE -
testcase_72 TLE -
testcase_73 TLE -
testcase_74 TLE -
testcase_75 TLE -
testcase_76 TLE -
testcase_77 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;

public class No1359 {
	
	private static long modpow(long x, long n, long m) {
		long ret = 1;
		while (n > 0) {
			if ((n & 1) != 0) {
				ret = ret * x % m;
			}
			x = x * x % m;
			n >>= 1;
		}
		return ret;
	}
	
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int K = scan.nextInt();
		int M = scan.nextInt();
		List<Integer> P = new ArrayList<Integer>();
		for (int i=0; i < N; i++) {
			P.add(scan.nextInt());
		}
		Collections.sort(P);
		List<Integer> E = new ArrayList<Integer>();
		for (int i=0; i < N; i++) {
			E.add(scan.nextInt());
		}
		Collections.sort(E);
		List<Integer> A = new ArrayList<Integer>();
		for (int i=0; i < N; i++) {
			A.add(scan.nextInt());
		}
		Collections.sort(A);
		List<Integer> H = new ArrayList<Integer>();
		for (int i=0; i < N; i++) {
			H.add(scan.nextInt());
		}
		Collections.sort(H);
		scan.close();
		long D = 0;
		long min = 0, max = 1;
		long startTime = System.currentTimeMillis();	
		for (int i=0; i < N; i++) {	
			int p = P.get(i);
			int e = E.get(i);
			min = Math.min(p, e);
			max = Math.max(p, e);
			int a = A.get(i);
			int h = H.get(i);
			min = Math.min(min, Math.min(a, h));
			max = Math.max(max, Math.max(a, h)); 
			D = (D + modpow(max - min, (long)K, (long)M)) % M;
		}
		System.out.println(System.currentTimeMillis()-startTime);
		System.out.println(D);
	}
}
0