結果

問題 No.1359 [Zelkova 3rd Tune] 四人セゾン
ユーザー 👑 箱
提出日時 2021-01-22 23:50:25
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 1,499 ms / 2,000 ms
コード長 1,267 bytes
コンパイル時間 14,740 ms
コンパイル使用メモリ 427,132 KB
実行使用メモリ 80,140 KB
最終ジャッジ日時 2023-08-28 08:45:32
合計ジャッジ時間 108,781 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 296 ms
53,692 KB
testcase_01 AC 298 ms
53,448 KB
testcase_02 AC 293 ms
53,488 KB
testcase_03 AC 1,047 ms
69,144 KB
testcase_04 AC 1,076 ms
71,404 KB
testcase_05 AC 1,006 ms
66,456 KB
testcase_06 AC 1,017 ms
71,212 KB
testcase_07 AC 1,103 ms
71,304 KB
testcase_08 AC 1,185 ms
72,468 KB
testcase_09 AC 713 ms
60,768 KB
testcase_10 AC 724 ms
61,628 KB
testcase_11 AC 1,452 ms
70,752 KB
testcase_12 AC 1,257 ms
72,116 KB
testcase_13 AC 1,022 ms
70,208 KB
testcase_14 AC 1,079 ms
70,028 KB
testcase_15 AC 998 ms
66,168 KB
testcase_16 AC 1,036 ms
66,212 KB
testcase_17 AC 1,332 ms
73,276 KB
testcase_18 AC 1,474 ms
73,348 KB
testcase_19 AC 1,421 ms
72,180 KB
testcase_20 AC 1,326 ms
71,596 KB
testcase_21 AC 1,377 ms
70,712 KB
testcase_22 AC 1,427 ms
71,532 KB
testcase_23 AC 1,055 ms
69,692 KB
testcase_24 AC 1,065 ms
70,204 KB
testcase_25 AC 603 ms
57,784 KB
testcase_26 AC 597 ms
58,836 KB
testcase_27 AC 865 ms
63,904 KB
testcase_28 AC 864 ms
63,592 KB
testcase_29 AC 925 ms
65,992 KB
testcase_30 AC 892 ms
65,400 KB
testcase_31 AC 998 ms
67,812 KB
testcase_32 AC 1,010 ms
66,268 KB
testcase_33 AC 898 ms
65,676 KB
testcase_34 AC 915 ms
65,800 KB
testcase_35 AC 972 ms
65,872 KB
testcase_36 AC 999 ms
68,548 KB
testcase_37 AC 596 ms
57,860 KB
testcase_38 AC 598 ms
58,864 KB
testcase_39 AC 575 ms
57,960 KB
testcase_40 AC 573 ms
57,800 KB
testcase_41 AC 694 ms
60,836 KB
testcase_42 AC 692 ms
60,660 KB
testcase_43 AC 659 ms
60,444 KB
testcase_44 AC 1,384 ms
73,324 KB
testcase_45 AC 913 ms
66,168 KB
testcase_46 AC 646 ms
58,344 KB
testcase_47 AC 1,134 ms
70,684 KB
testcase_48 AC 1,084 ms
72,480 KB
testcase_49 AC 1,064 ms
72,556 KB
testcase_50 AC 1,044 ms
70,852 KB
testcase_51 AC 470 ms
58,152 KB
testcase_52 AC 1,391 ms
72,084 KB
testcase_53 AC 1,434 ms
80,140 KB
testcase_54 AC 1,475 ms
77,864 KB
testcase_55 AC 1,293 ms
77,220 KB
testcase_56 AC 1,247 ms
77,344 KB
testcase_57 AC 1,283 ms
78,456 KB
testcase_58 AC 1,336 ms
79,356 KB
testcase_59 AC 1,405 ms
76,816 KB
testcase_60 AC 1,308 ms
78,260 KB
testcase_61 AC 1,485 ms
79,716 KB
testcase_62 AC 1,365 ms
79,040 KB
testcase_63 AC 1,325 ms
77,692 KB
testcase_64 AC 1,433 ms
77,172 KB
testcase_65 AC 1,436 ms
77,036 KB
testcase_66 AC 1,389 ms
77,432 KB
testcase_67 AC 1,461 ms
78,040 KB
testcase_68 AC 1,352 ms
79,400 KB
testcase_69 AC 1,397 ms
77,596 KB
testcase_70 AC 1,323 ms
77,668 KB
testcase_71 AC 1,246 ms
76,896 KB
testcase_72 AC 1,342 ms
78,300 KB
testcase_73 AC 1,374 ms
77,368 KB
testcase_74 AC 1,319 ms
77,336 KB
testcase_75 AC 1,499 ms
78,676 KB
testcase_76 AC 1,375 ms
79,492 KB
testcase_77 AC 1,379 ms
77,276 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.kt:28:26: warning: unnecessary non-null assertion (!!) on a non-null receiver of type Long
        val d = arr.max()!! - arr.min()!!
                         ^
Main.kt:28:40: warning: unnecessary non-null assertion (!!) on a non-null receiver of type Long
        val d = arr.max()!! - arr.min()!!
                                       ^

ソースコード

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.max()!! - arr.min()!!
        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