結果

問題 No.297 カードの数式
ユーザー TawaraTawara
提出日時 2015-11-10 16:07:32
言語 Python2
(2.7.18)
結果
AC  
実行時間 11 ms / 1,000 ms
コード長 472 bytes
コンパイル時間 72 ms
コンパイル使用メモリ 6,804 KB
実行使用メモリ 6,092 KB
最終ジャッジ日時 2023-08-26 22:50:01
合計ジャッジ時間 1,250 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 10 ms
5,976 KB
testcase_01 AC 10 ms
5,924 KB
testcase_02 AC 10 ms
5,860 KB
testcase_03 AC 10 ms
5,824 KB
testcase_04 AC 10 ms
5,924 KB
testcase_05 AC 10 ms
6,092 KB
testcase_06 AC 11 ms
5,980 KB
testcase_07 AC 11 ms
6,080 KB
testcase_08 AC 11 ms
5,920 KB
testcase_09 AC 11 ms
5,860 KB
testcase_10 AC 10 ms
5,928 KB
testcase_11 AC 10 ms
5,888 KB
testcase_12 AC 10 ms
6,080 KB
testcase_13 AC 10 ms
6,084 KB
testcase_14 AC 10 ms
5,920 KB
testcase_15 AC 10 ms
5,976 KB
testcase_16 AC 10 ms
5,920 KB
testcase_17 AC 10 ms
6,080 KB
testcase_18 AC 10 ms
5,852 KB
testcase_19 AC 10 ms
5,960 KB
testcase_20 AC 10 ms
5,924 KB
testcase_21 AC 10 ms
5,928 KB
testcase_22 AC 10 ms
5,980 KB
testcase_23 AC 10 ms
5,924 KB
testcase_24 AC 10 ms
5,996 KB
testcase_25 AC 10 ms
5,936 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(raw_input())
c = raw_input().split()
p = m = 0
inc = 0
while inc < N - p - m:
	if c[inc].isdigit():
		inc += 1
	elif c.pop(inc) == "+":
		p += 1
	else:
		m += 1
op = m + p
N -= op
c.sort(reverse = True)
max_v = int("".join(c[:N-op]))+sum(map(int,c[N-op:N-m]))-sum(map(int,c[N-m:]))
if m == 0:
	min_v = sum(int(c[i])*10**(i/(op+1)) for i in xrange(N))
else: 
	min_v = sum(map(int,c[N-(p+1):]))-sum(map(int,c[N-op:N-(p+1)]))-int("".join(c[:N-op]))
print max_v, min_v
0