結果
| 問題 |
No.3048 Swing
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-04-03 09:44:37 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 39 ms / 2,000 ms |
| コード長 | 529 bytes |
| コンパイル時間 | 167 ms |
| コンパイル使用メモリ | 82,172 KB |
| 実行使用メモリ | 53,600 KB |
| 最終ジャッジ日時 | 2025-06-20 02:28:55 |
| 合計ジャッジ時間 | 3,809 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 62 |
ソースコード
x,n=map(int,input().split())
l,r=0,10**10
while r-l>1:
c=(l+r)//2
if x>0:
if x-c*(c+1)//2>0:
l=c
else:
r=c
else:
if x+c*(c+1)//2>0:
r=c
else:
l=c
if x<=0:
l+=1
if n<=l:
stc=n*(n+1)//2
if x>0:
print(x-stc)
else:
print(x+stc)
else:
stc=l*(l+1)//2
if x>0:
now=x-stc
else:
now=x+stc
zan=n-l
if zan%2==0:
print(now+zan//2)
else:
print(now-l-1-(zan-1)//2)