結果

問題 No.1359 [Zelkova 3rd Tune] 四人セゾン
ユーザー 👑 箱
提出日時 2021-01-22 23:48:28
言語 Kotlin
(1.9.23)
結果
TLE  
実行時間 -
コード長 1,251 bytes
コンパイル時間 15,747 ms
コンパイル使用メモリ 428,208 KB
実行使用メモリ 97,748 KB
最終ジャッジ日時 2023-08-28 08:41:06
合計ジャッジ時間 162,914 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 294 ms
53,624 KB
testcase_01 AC 294 ms
53,708 KB
testcase_02 AC 293 ms
53,748 KB
testcase_03 AC 1,676 ms
74,340 KB
testcase_04 AC 1,534 ms
73,772 KB
testcase_05 AC 1,554 ms
71,604 KB
testcase_06 AC 1,555 ms
71,880 KB
testcase_07 AC 1,980 ms
80,920 KB
testcase_08 AC 1,927 ms
80,320 KB
testcase_09 AC 865 ms
62,976 KB
testcase_10 AC 842 ms
62,956 KB
testcase_11 TLE -
testcase_12 TLE -
testcase_13 AC 1,615 ms
78,032 KB
testcase_14 AC 1,690 ms
78,340 KB
testcase_15 AC 1,461 ms
73,844 KB
testcase_16 AC 1,541 ms
73,356 KB
testcase_17 TLE -
testcase_18 TLE -
testcase_19 TLE -
testcase_20 TLE -
testcase_21 TLE -
testcase_22 TLE -
testcase_23 AC 1,951 ms
80,184 KB
testcase_24 AC 1,795 ms
79,844 KB
testcase_25 AC 682 ms
60,852 KB
testcase_26 AC 671 ms
60,748 KB
testcase_27 AC 1,232 ms
67,148 KB
testcase_28 AC 1,131 ms
67,180 KB
testcase_29 AC 1,380 ms
71,584 KB
testcase_30 AC 1,282 ms
71,472 KB
testcase_31 AC 1,573 ms
76,408 KB
testcase_32 AC 1,580 ms
75,832 KB
testcase_33 AC 1,336 ms
69,888 KB
testcase_34 AC 1,305 ms
71,788 KB
testcase_35 AC 1,555 ms
74,952 KB
testcase_36 AC 1,666 ms
73,912 KB
testcase_37 AC 697 ms
60,320 KB
testcase_38 AC 692 ms
60,672 KB
testcase_39 AC 666 ms
60,624 KB
testcase_40 AC 650 ms
60,912 KB
testcase_41 AC 874 ms
62,992 KB
testcase_42 AC 851 ms
63,020 KB
testcase_43 AC 795 ms
60,888 KB
testcase_44 TLE -
testcase_45 AC 1,350 ms
71,584 KB
testcase_46 AC 770 ms
61,108 KB
testcase_47 TLE -
testcase_48 AC 1,996 ms
85,480 KB
testcase_49 AC 1,959 ms
81,764 KB
testcase_50 AC 1,491 ms
73,376 KB
testcase_51 AC 487 ms
58,364 KB
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 -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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 = Array(n) { nextLong() }
    val e = Array(n) { nextLong() }
    val a = Array(n) { nextLong() }
    val h = Array(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