結果

問題 No.1043 直列大学
ユーザー rutilicusrutilicus
提出日時 2020-10-10 11:44:40
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 948 ms / 2,000 ms
コード長 1,756 bytes
コンパイル時間 18,037 ms
コンパイル使用メモリ 427,444 KB
実行使用メモリ 222,212 KB
最終ジャッジ日時 2023-08-24 12:56:38
合計ジャッジ時間 38,041 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 349 ms
56,036 KB
testcase_01 AC 322 ms
56,176 KB
testcase_02 AC 404 ms
59,004 KB
testcase_03 AC 324 ms
56,352 KB
testcase_04 AC 323 ms
56,028 KB
testcase_05 AC 320 ms
55,988 KB
testcase_06 AC 341 ms
55,976 KB
testcase_07 AC 398 ms
59,236 KB
testcase_08 AC 396 ms
59,232 KB
testcase_09 AC 666 ms
128,228 KB
testcase_10 AC 732 ms
180,776 KB
testcase_11 AC 911 ms
222,212 KB
testcase_12 AC 948 ms
221,952 KB
testcase_13 AC 867 ms
221,216 KB
testcase_14 AC 889 ms
222,024 KB
testcase_15 AC 932 ms
222,092 KB
testcase_16 AC 881 ms
222,024 KB
testcase_17 AC 732 ms
180,852 KB
testcase_18 AC 742 ms
181,024 KB
testcase_19 AC 820 ms
180,800 KB
testcase_20 AC 727 ms
180,896 KB
testcase_21 AC 790 ms
180,760 KB
testcase_22 AC 808 ms
180,752 KB
testcase_23 AC 938 ms
222,032 KB
testcase_24 AC 768 ms
180,676 KB
testcase_25 AC 831 ms
180,816 KB
testcase_26 AC 891 ms
222,032 KB
testcase_27 AC 623 ms
124,692 KB
testcase_28 AC 825 ms
182,076 KB
testcase_29 AC 513 ms
88,684 KB
testcase_30 AC 723 ms
180,864 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.kt:57: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() }

    val vCnt = Array(n) { LongArray(100000 + 1) }
    val rCnt = Array(m) { LongArray(100000 + 1) }

    readInputLine().split(" ").forEachIndexed { index, s ->
        val v = s.toInt()
        if (index != 0) {
            for (i in 1..(100000 - v)) {
                vCnt[index][i] = (vCnt[index][i] + vCnt[index - 1][i]) % mod
                vCnt[index][i + v] = (vCnt[index][i + v] + vCnt[index - 1][i]) % mod
            }
        }
        vCnt[index][v] = (vCnt[index][v] + 1) % mod 
    }

    readInputLine().split(" ").forEachIndexed { index, s ->
        val r = s.toInt()
        if (index != 0) {
            for (i in 1..(100000 - r)) {
                rCnt[index][i] = (rCnt[index][i] + rCnt[index - 1][i]) % mod
                rCnt[index][i + r] = (rCnt[index][i + r] + rCnt[index - 1][i]) % mod
            }
        }
        rCnt[index][r] = (rCnt[index][r] + 1) % mod
    }

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

    var ans = 0L

    val vCntSum = LongArray(100000 + 1)

    for (i in 1..100000) {
        vCntSum[i] = vCnt[n - 1][i]
    }

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

    for (i in 1..100000) {
        if (rCnt[m - 1][i] != 0L) {
            val l = i.toLong() * a
            val r = (i.toLong() * b).coerceAtMost(100000)
            if (l <= r) {
                ans = (ans + (mod + vCntSum[r.toInt()] - vCntSum[l.toInt() - 1]) * rCnt[m - 1][i]) % mod
            }
        }
    }

    builder.appendln(ans)

    print(builder.toString())
}

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