結果

問題 No.1359 [Zelkova 3rd Tune] 四人セゾン
ユーザー 小野寺健小野寺健
提出日時 2021-12-17 15:18:00
言語 Go
(1.22.1)
結果
AC  
実行時間 785 ms / 2,000 ms
コード長 1,198 bytes
コンパイル時間 14,028 ms
コンパイル使用メモリ 207,176 KB
実行使用メモリ 14,564 KB
最終ジャッジ日時 2023-10-12 17:44:32
合計ジャッジ時間 66,196 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 2 ms
4,368 KB
testcase_02 AC 2 ms
4,372 KB
testcase_03 AC 446 ms
8,532 KB
testcase_04 AC 398 ms
8,288 KB
testcase_05 AC 381 ms
7,984 KB
testcase_06 AC 382 ms
7,968 KB
testcase_07 AC 555 ms
10,504 KB
testcase_08 AC 554 ms
10,504 KB
testcase_09 AC 151 ms
5,972 KB
testcase_10 AC 150 ms
5,968 KB
testcase_11 AC 701 ms
12,180 KB
testcase_12 AC 702 ms
12,180 KB
testcase_13 AC 454 ms
8,560 KB
testcase_14 AC 452 ms
8,564 KB
testcase_15 AC 392 ms
7,960 KB
testcase_16 AC 390 ms
7,956 KB
testcase_17 AC 738 ms
12,596 KB
testcase_18 AC 740 ms
12,620 KB
testcase_19 AC 645 ms
11,312 KB
testcase_20 AC 643 ms
11,312 KB
testcase_21 AC 698 ms
11,992 KB
testcase_22 AC 693 ms
11,956 KB
testcase_23 AC 480 ms
9,136 KB
testcase_24 AC 500 ms
9,132 KB
testcase_25 AC 77 ms
4,996 KB
testcase_26 AC 74 ms
4,988 KB
testcase_27 AC 246 ms
6,328 KB
testcase_28 AC 252 ms
6,324 KB
testcase_29 AC 304 ms
6,608 KB
testcase_30 AC 305 ms
6,740 KB
testcase_31 AC 410 ms
7,604 KB
testcase_32 AC 405 ms
7,604 KB
testcase_33 AC 302 ms
6,476 KB
testcase_34 AC 300 ms
6,704 KB
testcase_35 AC 417 ms
8,284 KB
testcase_36 AC 396 ms
8,288 KB
testcase_37 AC 79 ms
4,984 KB
testcase_38 AC 79 ms
4,988 KB
testcase_39 AC 64 ms
5,000 KB
testcase_40 AC 64 ms
5,052 KB
testcase_41 AC 142 ms
5,872 KB
testcase_42 AC 142 ms
5,876 KB
testcase_43 AC 115 ms
5,712 KB
testcase_44 AC 739 ms
12,776 KB
testcase_45 AC 311 ms
6,748 KB
testcase_46 AC 104 ms
5,024 KB
testcase_47 AC 519 ms
9,576 KB
testcase_48 AC 501 ms
9,560 KB
testcase_49 AC 509 ms
9,852 KB
testcase_50 AC 384 ms
7,988 KB
testcase_51 AC 19 ms
4,368 KB
testcase_52 AC 658 ms
11,644 KB
testcase_53 AC 769 ms
13,084 KB
testcase_54 AC 779 ms
13,340 KB
testcase_55 AC 778 ms
13,272 KB
testcase_56 AC 782 ms
14,308 KB
testcase_57 AC 782 ms
14,556 KB
testcase_58 AC 780 ms
14,556 KB
testcase_59 AC 780 ms
14,556 KB
testcase_60 AC 773 ms
14,564 KB
testcase_61 AC 761 ms
14,552 KB
testcase_62 AC 775 ms
14,556 KB
testcase_63 AC 778 ms
14,552 KB
testcase_64 AC 781 ms
14,556 KB
testcase_65 AC 776 ms
14,552 KB
testcase_66 AC 777 ms
14,540 KB
testcase_67 AC 785 ms
14,552 KB
testcase_68 AC 771 ms
14,556 KB
testcase_69 AC 758 ms
14,556 KB
testcase_70 AC 758 ms
14,552 KB
testcase_71 AC 747 ms
14,552 KB
testcase_72 AC 783 ms
14,552 KB
testcase_73 AC 776 ms
14,552 KB
testcase_74 AC 772 ms
14,556 KB
testcase_75 AC 775 ms
14,556 KB
testcase_76 AC 773 ms
14,556 KB
testcase_77 AC 771 ms
14,556 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

import (
	"fmt"
	"bufio"
	"os"
	"sort"
)

func modpow(x int, n int, m int) int {
	var ret int = 1
	for n > 0 {
		if (n & 1) != 0 {
			ret = ret * x % m
		}
		x = x * x % m
		n >>= 1
	}
	return ret
}

func Min(a int, b int) int {
	if a <= b {
		return a
	} else {
		return b
	}
}

func Max(a int, b int) int {
	if a >= b {
		return a
	} else {
		return b
	}
}

func main() {
	r := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
    defer w.Flush()
	var N, K, M int
	fmt.Fscan(r, &N, &K, &M)
	P := make([]int, N)
	for i := 0; i < N; i++ {
		var x int
		fmt.Fscan(r, &x)
		P[i] = x
	}
	sort.Ints(P)
	E := make([]int, N)
	for i := 0; i < N; i++ {
		var x int
		fmt.Fscan(r, &x)
		E[i] = x
	}
	sort.Ints(E)
	A := make([]int, N)
	for i := 0; i < N; i++ {
		var x int
		fmt.Fscan(r, &x)
		A[i] = x
	}
	sort.Ints(A)
	H := make([]int, N)
	for i := 0; i < N; i++ {
		var x int
		fmt.Fscan(r, &x)
		H[i] = x
	}
	sort.Ints(H)
	D := 0
	min := 0
	max := 1
	for i := 0; i < N; i++ {
		p := P[i]
		e := E[i]
		min = Min(p, e)
		max = Max(p, e)
		a := A[i]
		h := H[i]
		min = Min(min, Min(a, h))
		max = Max(max, Max(a, h))
		D = (D + modpow(max - min, K, M)) % M
	}
	fmt.Fprintln(w, D)
}
0