結果
問題 |
No.1150 シュークリームゲーム(Easy)
|
ユーザー |
![]() |
提出日時 | 2020-08-08 20:58:54 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 131 ms / 2,000 ms |
コード長 | 609 bytes |
コンパイル時間 | 113 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 21,608 KB |
最終ジャッジ日時 | 2024-10-02 04:34:55 |
合計ジャッジ時間 | 5,782 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 43 |
ソースコード
import sys input=lambda: sys.stdin.readline().rstrip() n=int(input()) s,t=map(int,input().split()) A=[int(i) for i in input().split()] sign=1 if s>t: s,t=t,s sign=-1 ans=0 s-=1 t-=1 dif=0 for i in range(n): if i<=s: if s-i<i+n-t: ans+=A[i] elif s-i==i+n-t: dif+=A[i] else: ans-=A[i] elif i<=t: if i-s<t-i: ans+=A[i] elif i-s==t-i: dif-=A[i] else: ans-=A[i] else: if n+s-i<i-t: ans+=A[i] elif n+s-i==i-t: dif+=A[i] else: ans-=A[i] if sign==1: if dif>=0: print(ans+dif) else: print(ans-dif) else: if dif>=0: print(-ans+dif) else: print(-ans-dif)