結果
| 問題 | No.1043 直列大学 |
| コンテスト | |
| ユーザー |
rutilicus
|
| 提出日時 | 2020-10-10 11:33:18 |
| 言語 | Kotlin (2.1.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,708 bytes |
| 記録 | |
| コンパイル時間 | 15,598 ms |
| コンパイル使用メモリ | 447,228 KB |
| 実行使用メモリ | 104,836 KB |
| 最終ジャッジ日時 | 2024-07-20 15:50:12 |
| 合計ジャッジ時間 | 25,432 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 7 RE * 2 TLE * 1 -- * 18 |
コンパイルメッセージ
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)
^
ソースコード
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()!!
}
rutilicus