結果

問題 No.297 カードの数式
ユーザー lip_of_cygnuslip_of_cygnus
提出日時 2015-11-07 00:23:34
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 622 bytes
コンパイル時間 245 ms
コンパイル使用メモリ 10,736 KB
実行使用メモリ 7,944 KB
最終ジャッジ日時 2023-10-11 14:43:27
合計ジャッジ時間 1,672 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
権限があれば一括ダウンロードができます

ソースコード

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