結果

問題 No.1043 直列大学
ユーザー rutilicusrutilicus
提出日時 2020-10-10 11:33:18
言語 Kotlin
(1.9.23)
結果
RE  
実行時間 -
コード長 1,708 bytes
コンパイル時間 18,226 ms
コンパイル使用メモリ 431,312 KB
実行使用メモリ 90,096 KB
最終ジャッジ日時 2023-09-27 21:18:12
合計ジャッジ時間 28,198 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 260 ms
55,228 KB
testcase_01 AC 262 ms
55,036 KB
testcase_02 AC 266 ms
53,416 KB
testcase_03 AC 264 ms
53,348 KB
testcase_04 AC 267 ms
53,708 KB
testcase_05 AC 265 ms
53,276 KB
testcase_06 AC 262 ms
53,248 KB
testcase_07 AC 267 ms
53,452 KB
testcase_08 AC 266 ms
53,796 KB
testcase_09 AC 378 ms
61,036 KB
testcase_10 RE -
testcase_11 RE -
testcase_12 TLE -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.kt:54:13: warning: 'appendln(Long): kotlin.text.StringBuilder /* = java.lang.StringBuilder */' is deprecated. Use appendLine instead. Note that the new method always appends the line feed character '\n' regardless of the system line separator.
    builder.appendln(ans)
            ^

ソースコード

diff #

fun main() {
    val builder = StringBuilder()

    val mod = 1000000007L

    val (n, m) = readInputLine().split(" ").map { it.toInt() }

    // value -> cnt
    val vCnt = Array(n) { mutableMapOf<Long, Long>() }
    val rCnt = Array(m) { mutableMapOf<Long, Long>() }

    readInputLine().split(" ").forEachIndexed { index, s ->
        val v = s.toLong()
        if (index != 0) {
            vCnt[index - 1].forEach {
                vCnt[index][it.key] = ((vCnt[index][it.key] ?: 0L) + it.value) % mod
                vCnt[index][it.key + v] = ((vCnt[index][it.key + v] ?: 0L) + it.value) % mod
            }
        }
        vCnt[index][v] = (vCnt[index][v] ?: 0L) + 1L
    }

    readInputLine().split(" ").forEachIndexed { index, s ->
        val r = s.toLong()
        if (index != 0) {
            rCnt[index - 1].forEach {
                rCnt[index][it.key] = ((rCnt[index][it.key] ?: 0L) + it.value) % mod
                rCnt[index][it.key + r] = ((rCnt[index][it.key + r] ?: 0L) + it.value) % mod
            }
        }
        rCnt[index][r] = (rCnt[index][r] ?: 0L) + 1L
    }

    val (a, b) = readInputLine().split(" ").map { it.toLong() }

    var ans = 0L

    val vCntSum = LongArray(100000 + 1)

    vCnt[n - 1].forEach { entry ->
        vCntSum[entry.key.toInt()] = entry.value
    }

    for (i in 1..100000) {
        vCntSum[i] = (vCntSum[i] + vCntSum[i - 1]) % mod
    }

    rCnt[m - 1].forEach { entry ->
        val l = entry.key * a
        val r = entry.key * b
        ans = (ans + (vCntSum[r.toInt()] - vCntSum[l.toInt() - 1]) * entry.value) % mod
    }

    builder.appendln(ans)

    print(builder.toString())
}

fun readInputLine(): String {
    return readLine()!!
}
0