結果
問題 | No.607 開通777年記念 |
ユーザー | qszhu |
提出日時 | 2022-10-08 23:23:49 |
言語 | Kotlin (1.9.23) |
結果 |
AC
|
実行時間 | 933 ms / 2,000 ms |
コード長 | 1,159 bytes |
コンパイル時間 | 17,717 ms |
コンパイル使用メモリ | 423,752 KB |
実行使用メモリ | 65,068 KB |
最終ジャッジ日時 | 2023-09-05 04:33:43 |
合計ジャッジ時間 | 24,695 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 314 ms
55,060 KB |
testcase_01 | AC | 304 ms
53,456 KB |
testcase_02 | AC | 302 ms
55,068 KB |
testcase_03 | AC | 301 ms
55,428 KB |
testcase_04 | AC | 304 ms
53,220 KB |
testcase_05 | AC | 304 ms
55,264 KB |
testcase_06 | AC | 301 ms
55,304 KB |
testcase_07 | AC | 555 ms
58,168 KB |
testcase_08 | AC | 304 ms
55,364 KB |
testcase_09 | AC | 378 ms
55,672 KB |
testcase_10 | AC | 369 ms
57,548 KB |
testcase_11 | AC | 933 ms
65,068 KB |
testcase_12 | AC | 793 ms
64,640 KB |
ソースコード
import kotlin.system.exitProcess val br = System.`in`.bufferedReader() fun readLine(): String? = br.readLine() fun readStrings() = readLine()?.split(" ")?.filter { it.isNotEmpty() } ?: listOf() fun readInts() = readStrings().map { it.toInt() }.toIntArray() const val MAX_STACK_SIZE: Long = 128 * 1024 * 1024 fun main() { val thread = Thread(null, ::run, "solve", MAX_STACK_SIZE) thread.setUncaughtExceptionHandler { _, e -> e.printStackTrace(); exitProcess(1) } thread.start() } fun run() { val (_, M) = readInts() val a = Array(M) { readInts() } output(solve(M, a)) } fun solve(M: Int, a: Array<IntArray>): Boolean { val row = a[0].clone() fun has777(): Boolean { var i = 0 var sum = 0 for (j in row.indices) { sum += row[j] while (i < j && sum > 777) sum -= row[i++] if (sum == 777) return true } return false } if (has777()) return true for (i in 1 until M) { for (j in row.indices) row[j] += a[i][j] if (has777()) return true } return false } fun output(res: Boolean) = println(if (res) "YES" else "NO")