結果
問題 |
No.3048 Swing
|
ユーザー |
|
提出日時 | 2025-03-07 21:51:41 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 574 bytes |
コンパイル時間 | 631 ms |
コンパイル使用メモリ | 82,388 KB |
実行使用メモリ | 54,376 KB |
最終ジャッジ日時 | 2025-03-07 21:51:46 |
合計ジャッジ時間 | 4,503 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 24 WA * 34 |
ソースコード
x, n = map(int, input().split()) if x < 0: f = 0 x *= -1 else: f = 1 def is_ok(arg): S = arg * (arg + 1) // 2 return S <= abs(x) def bs(ok, ng): while abs(ok - ng) > 1: mid = (ok + ng) // 2 if is_ok(mid): ok = mid else: ng = mid return ok m = bs(0, 10**9 * 2) if n <= m+1: S = n * (n+1) // 2 x += (-1) ** f * S print(x) exit() S = (m+2) * (m+1) // 2 x += (-1) ** f * S n -= m+1 if n % 2: x *= -1 n = -(-n//2) if x < 0: x = -(abs(x) + n) else: x = x + n print(x)