結果
問題 | No.944 煎っぞ! |
ユーザー | qszhu |
提出日時 | 2022-10-07 19:21:29 |
言語 | Kotlin (1.9.23) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,189 bytes |
コンパイル時間 | 18,202 ms |
コンパイル使用メモリ | 425,220 KB |
実行使用メモリ | 58,868 KB |
最終ジャッジ日時 | 2023-09-02 20:22:42 |
合計ジャッジ時間 | 38,405 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 510 ms
56,972 KB |
testcase_01 | AC | 488 ms
56,712 KB |
testcase_02 | AC | 493 ms
58,496 KB |
testcase_03 | AC | 490 ms
56,660 KB |
testcase_04 | AC | 484 ms
56,920 KB |
testcase_05 | AC | 496 ms
56,856 KB |
testcase_06 | AC | 484 ms
56,800 KB |
testcase_07 | AC | 494 ms
56,668 KB |
testcase_08 | AC | 492 ms
56,648 KB |
testcase_09 | AC | 486 ms
58,868 KB |
testcase_10 | AC | 304 ms
53,560 KB |
testcase_11 | AC | 384 ms
56,108 KB |
testcase_12 | AC | 356 ms
55,720 KB |
testcase_13 | AC | 299 ms
55,144 KB |
testcase_14 | AC | 386 ms
57,992 KB |
testcase_15 | AC | 357 ms
57,412 KB |
testcase_16 | WA | - |
testcase_17 | AC | 297 ms
55,052 KB |
testcase_18 | AC | 389 ms
56,268 KB |
testcase_19 | AC | 387 ms
58,088 KB |
testcase_20 | AC | 512 ms
56,928 KB |
testcase_21 | AC | 501 ms
58,540 KB |
testcase_22 | AC | 479 ms
56,916 KB |
testcase_23 | AC | 492 ms
56,660 KB |
testcase_24 | AC | 487 ms
56,868 KB |
testcase_25 | AC | 481 ms
58,800 KB |
testcase_26 | AC | 482 ms
56,672 KB |
testcase_27 | AC | 510 ms
56,076 KB |
testcase_28 | AC | 300 ms
49,756 KB |
testcase_29 | AC | 301 ms
49,472 KB |
testcase_30 | AC | 516 ms
55,636 KB |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | WA | - |
ソースコード
import kotlin.system.exitProcess val br = System.`in`.bufferedReader() fun readLine(): String? = br.readLine() fun readString() = readLine()!! fun readInt() = readString().toInt() 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 N = readInt() val a = readInts() output(solve(N, a)) } fun solve(N: Int, a: IntArray): Int { val preSum = a.scan(0, Int::plus) fun canDivide(target: Int): Boolean { var i = 0 for (j in 1..N) { val sum = preSum[j] - preSum[i] if (sum == target) i = j else if (sum > target) return false } return true } var res = 1 var i = 2 while (i * i <= preSum.last()) { val sum = preSum.last() / i if (canDivide(sum)) res = i i++ } return res } fun output(res: Int) = println(res)