結果
問題 | No.3048 Swing |
ユーザー |
|
提出日時 | 2025-03-07 21:15:33 |
言語 | Ruby (3.4.1) |
結果 |
WA
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 392 bytes |
コンパイル時間 | 309 ms |
コンパイル使用メモリ | 8,192 KB |
実行使用メモリ | 13,056 KB |
最終ジャッジ日時 | 2025-03-14 17:00:06 |
合計ジャッジ時間 | 7,014 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 58 WA * 1 |
コンパイルメッセージ
Syntax OK
ソースコード
x, n = gets.split.map(&:to_i) y = x.abs ac = n wa = -1 while ac - wa > 1 wj = (ac + wa) >> 1 sum = (1 .. wj).sum if sum >= y ac = wj else wa = wj end end ac = [ac - 1, 0].max current = x <= 0 ? x + (1 .. ac).sum : x - (1 .. ac).sum e = (n - ac) / 2 o = (n - ac) % 2 if current <= 0 current -= e current += n if o == 1 else current += e current -= n if o == 1 end puts current