結果

問題 No.193 筒の数式
ユーザー tookunn_1213tookunn_1213
提出日時 2017-01-04 23:00:09
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 31 ms / 1,000 ms
コード長 476 bytes
コンパイル時間 196 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-12-16 08:51:21
合計ジャッジ時間 1,553 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

def operator(s):
	op=[]
	for i in range(len(s)):
		if s[i]=='+' or s[i]=='-':
			op.append(s[i])
	return op
S=input()
ans=-10**18
for i in range(len(S)):
	s=S[i:]+S[:i]
	if s[0]=='-' or s[0]=='+' or s[-1]=='-' or s[-1]=='+':
		continue
	ss=[int(i) for i in s.replace('-',' ').replace('+',' ').split()]
	op=[i for i in s if i=='+' or i=='-']
	tmp=ss[0]
	for i in range(1,len(ss)):
		if op[i-1]=='+':
			tmp+=ss[i]
		elif op[i-1]=='-':
			tmp-=ss[i]
	ans=max(ans,tmp)
print(ans)
0