結果
| 問題 |
No.297 カードの数式
|
| コンテスト | |
| ユーザー |
rlangevin
|
| 提出日時 | 2024-01-18 00:23:50 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 711 bytes |
| コンパイル時間 | 221 ms |
| コンパイル使用メモリ | 82,264 KB |
| 実行使用メモリ | 53,888 KB |
| 最終ジャッジ日時 | 2024-09-28 03:13:31 |
| 合計ジャッジ時間 | 2,504 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 17 WA * 6 |
ソースコード
from copy import *
N = int(input())
C = list(input().split())
A = []
p, m = 0, 0
for c in C:
if c == "+":
p += 1
elif c == "-":
m += 1
else:
A.append(int(c))
B = deepcopy(A)
ma = 0
A.sort(reverse=True)
for i in range(m):
ma -= A.pop()
for i in range(p):
ma += A.pop()
v = ""
for a in A:
v += str(a)
ma += int(v)
mi = 0
B.sort(reverse=True)
if m:
p += 1
for i in range(m-1):
mi -= B.pop()
for i in range(p):
mi += B.pop()
v = ""
for b in B:
v += str(b)
mi -= int(v)
else:
S = [""] * (p + 1)
for i in range(len(B)):
S[i%(p+1)] += str(B[-1-i])
for s in S:
mi += int(s)
print(ma, mi)
rlangevin