結果

問題 No.871 かえるのうた
ユーザー wipexwipex
提出日時 2019-11-10 21:27:08
言語 Ruby
(3.3.0)
結果
AC  
実行時間 194 ms / 2,000 ms
コード長 779 bytes
コンパイル時間 610 ms
コンパイル使用メモリ 11,364 KB
実行使用メモリ 41,480 KB
最終ジャッジ日時 2023-08-20 09:30:47
合計ジャッジ時間 8,605 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 84 ms
15,304 KB
testcase_01 AC 85 ms
15,148 KB
testcase_02 AC 82 ms
15,136 KB
testcase_03 AC 83 ms
15,136 KB
testcase_04 AC 83 ms
15,184 KB
testcase_05 AC 86 ms
15,288 KB
testcase_06 AC 85 ms
15,276 KB
testcase_07 AC 85 ms
15,140 KB
testcase_08 AC 87 ms
15,308 KB
testcase_09 AC 86 ms
15,472 KB
testcase_10 AC 83 ms
15,332 KB
testcase_11 AC 84 ms
15,152 KB
testcase_12 AC 96 ms
17,076 KB
testcase_13 AC 84 ms
15,440 KB
testcase_14 AC 186 ms
33,264 KB
testcase_15 AC 184 ms
33,516 KB
testcase_16 AC 194 ms
41,480 KB
testcase_17 AC 176 ms
31,988 KB
testcase_18 AC 96 ms
18,220 KB
testcase_19 AC 186 ms
33,568 KB
testcase_20 AC 88 ms
16,500 KB
testcase_21 AC 120 ms
23,056 KB
testcase_22 AC 82 ms
15,148 KB
testcase_23 AC 80 ms
15,144 KB
testcase_24 AC 80 ms
15,100 KB
testcase_25 AC 83 ms
15,560 KB
testcase_26 AC 88 ms
15,860 KB
testcase_27 AC 102 ms
16,768 KB
testcase_28 AC 85 ms
15,112 KB
testcase_29 AC 134 ms
23,968 KB
testcase_30 AC 167 ms
23,884 KB
testcase_31 AC 88 ms
15,448 KB
testcase_32 AC 154 ms
22,984 KB
testcase_33 AC 174 ms
31,440 KB
testcase_34 AC 103 ms
19,116 KB
testcase_35 AC 128 ms
24,808 KB
testcase_36 AC 163 ms
25,360 KB
testcase_37 AC 124 ms
22,732 KB
testcase_38 AC 179 ms
32,900 KB
testcase_39 AC 177 ms
32,376 KB
testcase_40 AC 152 ms
21,412 KB
testcase_41 AC 87 ms
15,168 KB
testcase_42 AC 152 ms
21,484 KB
testcase_43 AC 85 ms
15,276 KB
testcase_44 AC 91 ms
15,264 KB
testcase_45 AC 88 ms
15,156 KB
testcase_46 AC 94 ms
15,132 KB
testcase_47 AC 91 ms
15,148 KB
testcase_48 AC 88 ms
15,104 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:26: warning: assigned but unused variable - p
Syntax OK

ソースコード

diff #

@x=[];a=[];@t=[]
n,k = gets.chomp.split(" ").map(&:to_i)
@x+=gets.chomp.split(" ").map(&:to_i)
a+=gets.chomp.split(" ").map(&:to_i)

def max(a,b)
 if a > b
   return a
 elsif b > a
   return b
 else
   return a
 end
end

def min(a,b)
 if a > b
   return b
 elsif b > a
   return a
 else
   return a
 end
end

p=@x[k-1]

l = r = k - 1
ld, rd = @x[k - 1] - a[k - 1], @x[k - 1] + a[k - 1]

updated = true
while(updated)
    updated = false

    while (l - 1 >= 0) and (ld <= @x[l - 1])
        updated = true
        l -= 1
        ld = min(ld, @x[l] - a[l])
        rd = max(rd, @x[l] + a[l])
    end

    while (r + 1 < n) and (rd >= @x[r + 1])
        updated = true
        r += 1
        ld = min(ld, @x[r] - a[r])
        rd = max(rd, @x[r] + a[r])
    end
end

p (r - l + 1)
0