結果

問題 No.297 カードの数式
ユーザー lip_of_cygnuslip_of_cygnus
提出日時 2015-11-07 00:25:06
言語 Python2
(2.7.18)
結果
AC  
実行時間 12 ms / 1,000 ms
コード長 620 bytes
コンパイル時間 654 ms
コンパイル使用メモリ 6,720 KB
実行使用メモリ 6,232 KB
最終ジャッジ日時 2023-08-26 22:49:05
合計ジャッジ時間 1,778 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 10 ms
6,024 KB
testcase_01 AC 10 ms
5,972 KB
testcase_02 AC 10 ms
5,964 KB
testcase_03 AC 10 ms
6,044 KB
testcase_04 AC 9 ms
5,980 KB
testcase_05 AC 10 ms
5,972 KB
testcase_06 AC 10 ms
6,156 KB
testcase_07 AC 10 ms
5,992 KB
testcase_08 AC 11 ms
6,056 KB
testcase_09 AC 11 ms
6,112 KB
testcase_10 AC 11 ms
6,116 KB
testcase_11 AC 11 ms
6,228 KB
testcase_12 AC 12 ms
6,212 KB
testcase_13 AC 10 ms
5,996 KB
testcase_14 AC 11 ms
6,060 KB
testcase_15 AC 10 ms
5,996 KB
testcase_16 AC 11 ms
5,980 KB
testcase_17 AC 11 ms
6,056 KB
testcase_18 AC 10 ms
5,976 KB
testcase_19 AC 11 ms
6,032 KB
testcase_20 AC 11 ms
5,976 KB
testcase_21 AC 11 ms
6,056 KB
testcase_22 AC 11 ms
5,980 KB
testcase_23 AC 10 ms
6,064 KB
testcase_24 AC 11 ms
6,232 KB
testcase_25 AC 11 ms
5,992 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys

n=int(input())
l=raw_input().split()
k=0
m=0
p=0
j=0
x=0
a=[]
for i in range (0,n): 
	if l[i]=="+":
		p=p+1
	elif l[i]=="-":
		m=m+1
	else:
		a.append(int(l[i]))
a.sort()
for i in range (0,len(a)):
	if i<m: 
		k=k-a[i]
	elif i<m+p: 
		k=k+a[i]
	else: 
		k=k+a[i]*10**j
		j=j+1

if m==0:
	a.reverse()
	for i in range (0,len(a)): 
		x=x+a[i]*10**( i/(p+1) )
else:
	for i in range (0,len(a)):
		if i<p+1: 
			x=x+a[i]
		elif i<p+m: 
			x=x-a[i]
		else: 
			x=x-a[i]*10**(i-p-m)	
print k,x


'''
+パート
最大の整数
マイナスパート
最小の整数

'''
0