結果

問題 No.152 貯金箱の消失
ユーザー バカらっくバカらっく
提出日時 2019-11-05 01:32:48
言語 Kotlin
(1.9.23)
結果
TLE  
実行時間 -
コード長 1,271 bytes
コンパイル時間 14,689 ms
コンパイル使用メモリ 428,480 KB
実行使用メモリ 69,748 KB
最終ジャッジ日時 2023-10-13 02:12:56
合計ジャッジ時間 24,571 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 274 ms
52,196 KB
testcase_01 AC 531 ms
69,748 KB
testcase_02 AC 265 ms
50,468 KB
testcase_03 AC 455 ms
65,140 KB
testcase_04 TLE -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.kt:3:10: warning: parameter 'arr' is never used
fun main(arr:Array<String>) {
         ^
Main.kt:34:21: warning: variable 'keyKey' is never used
                val keyKey = dic[key!!*k]
                    ^
Main.kt:34:37: warning: unnecessary non-null assertion (!!) on a non-null receiver of type Int
                val keyKey = dic[key!!*k]
                                    ^

ソースコード

diff #


fun main(arr:Array<String>) {
    val dic = mutableMapOf<Int, Int>()
    val himo = readLine()!!.toInt()
    for (i in (1..himo)) {
        if(i*2*4>himo) {
            break
        }
        dic[i*i] = i
    }
    var ans = 0
    val flag = mutableMapOf<Int, MutableMap<Int, Boolean>>()
    for(i in dic.keys) {
        for(j in dic.keys.filter { it < i }) {
            val key = i - j
            if(key > j) {
                continue
            }
            if(!dic.containsKey(key)) {
                continue
            }
            if(flag.containsKey(dic[i]!!) && flag[dic[i]!!]!!.containsKey(dic[j]!!)) {
                continue
            }
            val requireHimo = (dic[i]!! + dic[j]!! + dic[key]!!) * 4
            if(requireHimo > himo) {
                continue
            }
            ans++
            for (k in (1..himo)) {
                val keyI = dic[i]!!*k
                val keyJ = dic[j]!!*k
                val keyKey = dic[key!!*k]
                if(!flag.containsKey(keyI)) {
                    flag[keyI] = mutableMapOf()
                }
                if(requireHimo * k > himo) {
                    break
                }
                flag[keyI]!![keyJ] = true
            }
        }
    }
    println(ans)
}


0