結果
問題 |
No.281 門松と魔法(1)
|
ユーザー |
|
提出日時 | 2015-10-29 05:38:11 |
言語 | Crystal (1.14.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 543 bytes |
コンパイル時間 | 13,265 ms |
コンパイル使用メモリ | 297,964 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-30 18:51:26 |
合計ジャッジ時間 | 13,803 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 9 WA * 38 RE * 10 |
ソースコード
#!/usr/bin/env crystal def solve_short(d,a,b,c) r=0 if a==c c=[0,c-d].max r+=1 end t=b-[a,c].min+1 if t>0 cnt=(t+d-1)/d r+=cnt b=[0,b-r*d].max end a==b || b==c ? -1 : r end def solve_tall(d,a,b,c) r=0 t=a-b+1 if t>0 cnt=(t+d-1)/d r+=cnt a=[0,a-cnt*d].max end t=c-b+1 if t>0 cnt=(t+d-1)/d r+=cnt c=[0,c-cnt*d].max end if a==c c=[0,c-d].max r+=1 end a==b || b==c ? -1 : r end d,a,b,c=4.times.map{gets.not_nil!.to_i}.to_a x=solve_short(d,a,b,c) y=solve_tall(d,a,b,c) p x>=0&&y>=0 ? [x,y].min : [x,y].max