結果

問題 No.873 バイナリ、ヤバいなり!w
ユーザー yukikurage_2019yukikurage_2019
提出日時 2019-09-12 15:15:56
言語 Kotlin
(1.9.23)
結果
TLE  
実行時間 -
コード長 1,161 bytes
コンパイル時間 17,196 ms
コンパイル使用メモリ 429,168 KB
実行使用メモリ 44,444 KB
最終ジャッジ日時 2023-09-15 14:15:04
合計ジャッジ時間 21,034 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

fun main() {
    val n = readLine()!!.toInt()
    val sqrtn = Math.sqrt(n.toDouble()).toInt()
    val dp = Array(sqrtn){Array(n+1){it}}
    val memo = Array(sqrtn){Array(n+1){it}}
    for(i in 1 until sqrtn)for(j in 0 until n+1){
        dp[i][j] = 100000//inf
        var count = 0
        for(k in j downTo 0 step (i+1)*(i+1)){
            if(dp[i-1][k]+i*count<dp[i][j]){
                dp[i][j] = dp[i-1][k]+i*count
                memo[i][j] = count
            }
            count++
        }
    }
    val ansList = mutableListOf<Int>()
    var l = n
    for(i in sqrtn - 1 downTo 0){
        for(j in 0 until memo[i][l]){
            ansList += i+1
            l-=(i+1)*(i+1)
        }
    }
    var ans = ansList.filter{it%2==1}.asReversed().toMutableList()
    val even = ansList.filter{it%2==0}
    ans = ans.plus(Array(even.count()){
        if(it%2==0)even[it/2]
        else even[even.count()-(it+1)/2]
    }).toMutableList()
    println(ans)
    var suf = 0
    for(i in ans){
        for(j in 0 until i){
            print(suf)
            suf=rev(suf)
        }
        suf=rev(suf)
    }
    println("")
}
fun rev(suf:Int)=if(suf==0)1 else 0
0