結果
| 問題 |
No.2015 Stair Counter
|
| コンテスト | |
| ユーザー |
horiesiniti
|
| 提出日時 | 2023-04-24 22:56:30 |
| 言語 | Ruby (3.4.1) |
| 結果 |
AC
|
| 実行時間 | 295 ms / 2,000 ms |
| コード長 | 532 bytes |
| コンパイル時間 | 904 ms |
| コンパイル使用メモリ | 7,296 KB |
| 実行使用メモリ | 27,264 KB |
| 最終ジャッジ日時 | 2024-11-08 23:40:52 |
| 合計ジャッジ時間 | 8,579 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 25 |
コンパイルメッセージ
Main.rb:2: warning: assigned but unused variable - ans Syntax OK
ソースコード
def f(n,m,xs)
ans="No"
if n==1 then
return "Yes" if xs[0]==m
return "No"
elsif n==2 then
return "Yes" if xs[0]<=xs[1] && xs[1]==m
return "No"
elsif xs[-1]==m then
t=m-xs[0]
return "No" if t<0
xs=[t]+xs
n=xs.size
#
(1..n-3).each{|i|
t3=xs[i+1]-xs[i-1]
t4=xs[i]-t3
t5=xs[i+2]-t4
t6=xs[i+1]-t5
#p [t3,t4,t5,t6]
return "No" if [t3,t4,t5,t6].any?{|e| e<0}
xs[i]=t4
}
return "Yes"
end
return "No"
end
t=gets.to_i
t.times{
a,b=gets.split(" ").map{|e| e.to_i}
xs=gets.split(" ").map{|e| e.to_i}
puts f(a,b,xs)
}
horiesiniti