結果

問題 No.1150 シュークリームゲーム(Easy)
ユーザー takakintakakin
提出日時 2020-08-08 20:55:19
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 919 bytes
コンパイル時間 117 ms
コンパイル使用メモリ 12,928 KB
実行使用メモリ 21,784 KB
最終ジャッジ日時 2024-04-10 02:24:04
合計ジャッジ時間 5,411 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
10,880 KB
testcase_01 AC 29 ms
10,752 KB
testcase_02 AC 31 ms
10,880 KB
testcase_03 AC 31 ms
10,880 KB
testcase_04 AC 30 ms
10,880 KB
testcase_05 AC 29 ms
10,752 KB
testcase_06 AC 30 ms
10,880 KB
testcase_07 AC 30 ms
10,880 KB
testcase_08 AC 29 ms
10,880 KB
testcase_09 AC 29 ms
10,752 KB
testcase_10 AC 30 ms
10,752 KB
testcase_11 AC 29 ms
10,752 KB
testcase_12 AC 31 ms
10,880 KB
testcase_13 WA -
testcase_14 AC 29 ms
10,880 KB
testcase_15 AC 30 ms
10,752 KB
testcase_16 AC 30 ms
10,880 KB
testcase_17 AC 31 ms
10,880 KB
testcase_18 WA -
testcase_19 AC 30 ms
10,880 KB
testcase_20 WA -
testcase_21 AC 29 ms
10,752 KB
testcase_22 AC 106 ms
20,180 KB
testcase_23 WA -
testcase_24 AC 110 ms
19,504 KB
testcase_25 AC 104 ms
19,960 KB
testcase_26 AC 117 ms
20,944 KB
testcase_27 AC 110 ms
21,180 KB
testcase_28 AC 125 ms
21,592 KB
testcase_29 AC 107 ms
19,772 KB
testcase_30 AC 108 ms
20,536 KB
testcase_31 WA -
testcase_32 AC 114 ms
20,052 KB
testcase_33 WA -
testcase_34 AC 110 ms
21,084 KB
testcase_35 AC 121 ms
21,192 KB
testcase_36 AC 127 ms
21,500 KB
testcase_37 WA -
testcase_38 AC 105 ms
19,824 KB
testcase_39 AC 101 ms
19,968 KB
testcase_40 AC 115 ms
20,500 KB
testcase_41 WA -
testcase_42 AC 112 ms
17,628 KB
testcase_43 AC 112 ms
17,628 KB
testcase_44 AC 120 ms
21,784 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

a,b=t-s-1,n-(t-s+1)
ans=0
s-=1
t-=1
if a%2==0 or b%2==0:
	for i in range(n):
		if i<=s:
			if s-i<=i+n-t:
				ans+=A[i]
			else:
				ans-=A[i]
		elif i<=t:
			if i-s<=t-i:
				ans+=A[i]
			else:
				ans-=A[i]
		else:
			if n+s-i<=i-t:
				ans+=A[i]
			else:
				ans-=A[i]
	print(sign*ans)
else:
	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)
0