結果
問題 | No.1150 シュークリームゲーム(Easy) |
ユーザー |
![]() |
提出日時 | 2025-03-26 15:57:26 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,679 bytes |
コンパイル時間 | 382 ms |
コンパイル使用メモリ | 82,424 KB |
実行使用メモリ | 90,288 KB |
最終ジャッジ日時 | 2025-03-26 15:58:09 |
合計ジャッジ時間 | 7,798 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 13 WA * 8 TLE * 1 -- * 21 |
ソースコード
n = int(input())s, t = map(int, input().split())a = list(map(int, input().split()))used = [False] * (n + 1) # 1-based indexingused[s] = Trueused[t] = Truex = a[s-1]y = a[t-1]# 315's territory boundariesl1 = r1 = s# 8128's territory boundariesl2 = r2 = tturn = 0 # 0 for 315, 1 for 8128while True:all_used = Truefor i in range(1, n+1):if not used[i]:all_used = Falsebreakif all_used:breakif turn % 2 == 0:# 315's turnleft = l1 - 1 if l1 > 1 else nright = r1 + 1 if r1 < n else 1candidates = []if not used[left]:candidates.append((a[left-1], left, 'left'))if not used[right]:candidates.append((a[right-1], right, 'right'))if candidates:candidates.sort(reverse=True, key=lambda x: x[0])val, pos, dir = candidates[0]x += valused[pos] = Trueif dir == 'left':l1 = poselse:r1 = poselse:# 8128's turnleft = l2 - 1 if l2 > 1 else nright = r2 + 1 if r2 < n else 1candidates = []if not used[left]:candidates.append((a[left-1], left, 'left'))if not used[right]:candidates.append((a[right-1], right, 'right'))if candidates:candidates.sort(reverse=True, key=lambda x: x[0])val, pos, dir = candidates[0]y += valused[pos] = Trueif dir == 'left':l2 = poselse:r2 = posturn += 1print(x - y)