結果

問題 No.1150 シュークリームゲーム(Easy)
ユーザー takakintakakin
提出日時 2020-08-08 20:58:54
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 125 ms / 2,000 ms
コード長 609 bytes
コンパイル時間 159 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 21,656 KB
最終ジャッジ日時 2024-04-10 03:12:21
合計ジャッジ時間 5,072 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
10,752 KB
testcase_01 AC 27 ms
10,880 KB
testcase_02 AC 26 ms
10,880 KB
testcase_03 AC 27 ms
10,752 KB
testcase_04 AC 26 ms
10,880 KB
testcase_05 AC 27 ms
10,752 KB
testcase_06 AC 26 ms
10,624 KB
testcase_07 AC 27 ms
10,752 KB
testcase_08 AC 27 ms
10,752 KB
testcase_09 AC 27 ms
10,880 KB
testcase_10 AC 27 ms
10,752 KB
testcase_11 AC 26 ms
10,624 KB
testcase_12 AC 26 ms
10,752 KB
testcase_13 AC 27 ms
10,880 KB
testcase_14 AC 31 ms
10,752 KB
testcase_15 AC 28 ms
10,752 KB
testcase_16 AC 26 ms
10,880 KB
testcase_17 AC 26 ms
10,752 KB
testcase_18 AC 25 ms
10,752 KB
testcase_19 AC 26 ms
10,752 KB
testcase_20 AC 27 ms
10,880 KB
testcase_21 AC 26 ms
10,880 KB
testcase_22 AC 102 ms
20,076 KB
testcase_23 AC 104 ms
20,312 KB
testcase_24 AC 104 ms
19,440 KB
testcase_25 AC 100 ms
19,844 KB
testcase_26 AC 114 ms
20,888 KB
testcase_27 AC 115 ms
21,248 KB
testcase_28 AC 113 ms
21,656 KB
testcase_29 AC 101 ms
19,716 KB
testcase_30 AC 110 ms
20,600 KB
testcase_31 AC 106 ms
20,272 KB
testcase_32 AC 112 ms
20,036 KB
testcase_33 AC 110 ms
20,508 KB
testcase_34 AC 110 ms
20,900 KB
testcase_35 AC 122 ms
21,128 KB
testcase_36 AC 116 ms
21,436 KB
testcase_37 AC 121 ms
21,652 KB
testcase_38 AC 101 ms
19,764 KB
testcase_39 AC 103 ms
19,780 KB
testcase_40 AC 105 ms
20,568 KB
testcase_41 AC 119 ms
21,228 KB
testcase_42 AC 112 ms
17,564 KB
testcase_43 AC 117 ms
17,568 KB
testcase_44 AC 125 ms
21,600 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


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)
0