結果

問題 No.871 かえるのうた
ユーザー face4face4
提出日時 2021-04-07 13:20:57
言語 Kotlin
(1.9.23)
結果
WA  
実行時間 -
コード長 752 bytes
コンパイル時間 16,646 ms
コンパイル使用メモリ 417,688 KB
実行使用メモリ 62,272 KB
最終ジャッジ日時 2023-09-04 11:51:57
合計ジャッジ時間 40,146 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

fun main(){
    var (n, k) = readLine()!!.split(" ").map{it.toInt()}
    val x = readLine()!!.split(" ").map{it.toInt()}
    val a = readLine()!!.split(" ").map{it.toInt()}
    
    k--
    var lindex = k
    var rindex = k
    var lpos = x[lindex]-a[lindex]
    var rpos = x[rindex]+a[rindex]

    while(true){
        if(lindex > 0 && lpos <= x[lindex-1]){
            lindex--
            lpos = Math.min(lpos, x[lindex]-a[lindex])
            rpos = Math.max(rpos, x[lindex]+a[lindex])
        }else if(rindex+1 < n && x[rindex+1] <= rpos){
            rindex++
            lpos = Math.min(lpos, x[rindex]-a[rindex])
            rpos = Math.max(rpos, x[rindex]+a[rindex])
        }else{
            break
        }
    }

    println(rpos-lpos+1)
}
0