結果

問題 No.1359 [Zelkova 3rd Tune] 四人セゾン
ユーザー 👑 箱
提出日時 2021-09-09 22:41:49
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 1,598 ms / 2,000 ms
コード長 1,279 bytes
コンパイル時間 17,294 ms
コンパイル使用メモリ 422,216 KB
実行使用メモリ 81,332 KB
最終ジャッジ日時 2023-09-07 22:02:53
合計ジャッジ時間 121,142 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 309 ms
51,204 KB
testcase_01 AC 309 ms
51,412 KB
testcase_02 AC 304 ms
51,120 KB
testcase_03 AC 1,110 ms
66,260 KB
testcase_04 AC 1,038 ms
65,264 KB
testcase_05 AC 1,012 ms
65,156 KB
testcase_06 AC 1,002 ms
65,408 KB
testcase_07 AC 1,273 ms
70,356 KB
testcase_08 AC 1,306 ms
70,104 KB
testcase_09 AC 772 ms
59,084 KB
testcase_10 AC 747 ms
60,620 KB
testcase_11 AC 1,271 ms
70,572 KB
testcase_12 AC 1,493 ms
69,740 KB
testcase_13 AC 1,076 ms
69,632 KB
testcase_14 AC 1,086 ms
70,068 KB
testcase_15 AC 1,050 ms
66,076 KB
testcase_16 AC 1,095 ms
66,008 KB
testcase_17 AC 1,346 ms
73,248 KB
testcase_18 AC 1,499 ms
74,224 KB
testcase_19 AC 1,421 ms
72,460 KB
testcase_20 AC 1,368 ms
72,132 KB
testcase_21 AC 1,269 ms
71,316 KB
testcase_22 AC 1,409 ms
71,160 KB
testcase_23 AC 1,087 ms
69,836 KB
testcase_24 AC 1,087 ms
70,488 KB
testcase_25 AC 610 ms
58,520 KB
testcase_26 AC 619 ms
58,276 KB
testcase_27 AC 899 ms
63,740 KB
testcase_28 AC 888 ms
63,660 KB
testcase_29 AC 938 ms
66,476 KB
testcase_30 AC 950 ms
65,796 KB
testcase_31 AC 1,031 ms
65,912 KB
testcase_32 AC 1,025 ms
66,076 KB
testcase_33 AC 1,025 ms
65,520 KB
testcase_34 AC 941 ms
65,716 KB
testcase_35 AC 1,063 ms
66,088 KB
testcase_36 AC 1,078 ms
66,072 KB
testcase_37 AC 624 ms
58,388 KB
testcase_38 AC 628 ms
58,240 KB
testcase_39 AC 606 ms
57,652 KB
testcase_40 AC 595 ms
57,692 KB
testcase_41 AC 739 ms
61,748 KB
testcase_42 AC 765 ms
60,628 KB
testcase_43 AC 684 ms
62,868 KB
testcase_44 AC 1,315 ms
73,916 KB
testcase_45 AC 1,015 ms
66,244 KB
testcase_46 AC 671 ms
58,324 KB
testcase_47 AC 1,215 ms
69,812 KB
testcase_48 AC 1,099 ms
71,956 KB
testcase_49 AC 1,185 ms
72,676 KB
testcase_50 AC 1,065 ms
66,004 KB
testcase_51 AC 493 ms
58,180 KB
testcase_52 AC 1,324 ms
71,528 KB
testcase_53 AC 1,367 ms
81,332 KB
testcase_54 AC 1,410 ms
78,212 KB
testcase_55 AC 1,311 ms
78,316 KB
testcase_56 AC 1,448 ms
78,304 KB
testcase_57 AC 1,408 ms
77,628 KB
testcase_58 AC 1,460 ms
79,400 KB
testcase_59 AC 1,399 ms
78,328 KB
testcase_60 AC 1,411 ms
78,756 KB
testcase_61 AC 1,448 ms
79,348 KB
testcase_62 AC 1,490 ms
79,604 KB
testcase_63 AC 1,352 ms
78,612 KB
testcase_64 AC 1,409 ms
78,784 KB
testcase_65 AC 1,418 ms
78,356 KB
testcase_66 AC 1,481 ms
77,452 KB
testcase_67 AC 1,595 ms
78,548 KB
testcase_68 AC 1,527 ms
81,100 KB
testcase_69 AC 1,261 ms
78,072 KB
testcase_70 AC 1,598 ms
78,644 KB
testcase_71 AC 1,426 ms
77,184 KB
testcase_72 AC 1,351 ms
78,624 KB
testcase_73 AC 1,357 ms
78,644 KB
testcase_74 AC 1,328 ms
78,340 KB
testcase_75 AC 1,337 ms
77,528 KB
testcase_76 AC 1,522 ms
79,380 KB
testcase_77 AC 1,402 ms
78,228 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.PrintWriter
import java.util.*
import kotlin.math.*

fun modpow(a: Long, e: Long, m: Long): Long {
    if (e == 0L) return 1 % m
    if (e == 1L) return a % m
    val b = modpow(a, e / 2, m)
    if (e % 2 == 0L) return b * b % m
    else return (b * b % m) * a % m
}

fun PrintWriter.solve() {
    val n = nextInt()
    val k = nextLong()
    val m = nextLong()
    val p = LongArray(n) { nextLong() }
    val e = LongArray(n) { nextLong() }
    val a = LongArray(n) { nextLong() }
    val h = LongArray(n) { nextLong() }
    p.sort()
    e.sort()
    a.sort()
    h.sort()
    var ans = 0L
    for (i in 0 until n) {
        val arr = arrayOf(p[i], e[i], a[i], h[i])
        val d = arr.maxOrNull()!! - arr.minOrNull()!!
        ans += modpow(d, k, m)
        ans %= m
    }
    println(ans)
}

fun main() {
    val writer = PrintWriter(System.out, false)
    writer.solve()
    writer.flush()
}

// region Scanner
private var st = StringTokenizer("")
private val br = System.`in`.bufferedReader()

fun next(): String {
    while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())
    return st.nextToken()
}

fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextLine() = br.readLine()!!
fun nextDouble() = next().toDouble()
// endregion
0