結果
問題 | No.518 ローマ数字の和 |
ユーザー | Schnee |
提出日時 | 2019-09-24 23:18:09 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,470 bytes |
コンパイル時間 | 116 ms |
コンパイル使用メモリ | 12,928 KB |
実行使用メモリ | 11,264 KB |
最終ジャッジ日時 | 2024-09-19 14:27:35 |
合計ジャッジ時間 | 1,902 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 34 ms
11,008 KB |
testcase_01 | AC | 33 ms
10,880 KB |
testcase_02 | WA | - |
testcase_03 | AC | 33 ms
11,008 KB |
testcase_04 | AC | 33 ms
11,008 KB |
testcase_05 | AC | 33 ms
10,880 KB |
testcase_06 | AC | 33 ms
11,136 KB |
testcase_07 | AC | 33 ms
11,136 KB |
testcase_08 | RE | - |
testcase_09 | AC | 34 ms
11,008 KB |
testcase_10 | RE | - |
testcase_11 | WA | - |
testcase_12 | RE | - |
testcase_13 | RE | - |
testcase_14 | AC | 34 ms
11,008 KB |
testcase_15 | AC | 34 ms
11,008 KB |
testcase_16 | RE | - |
testcase_17 | AC | 34 ms
11,136 KB |
testcase_18 | AC | 34 ms
10,880 KB |
testcase_19 | AC | 34 ms
10,880 KB |
testcase_20 | AC | 33 ms
11,008 KB |
testcase_21 | AC | 34 ms
11,008 KB |
ソースコード
import copy n = int(input().strip()) nums = input().strip().split() pri_dic = {"DCCC":800,"LXXX":80,"VIII":8,"MMM":3000,"DCC":700,"CCC":300,"LXX":70,"XXX":30,"VII":7,"III":3,"MM":2000,"CM":900,"DC":600,"CD":400,"CC":200,"XC":90,"LX":60,"XL":40,"XX":20,"IX":9, "VI":6,"IV":4,"II":2,"M":1000,"D":500,"C":100,"L":50,"X":10,"V":5,"I":1} pri_lis = ["DCCC","LXXX","VIII"] pri_lis2 = ["MMM","DCC","CCC","LXX","XXX","VII","III"] pri_lis3 = ["MM","CM","DC","CD","CC","XC","LX","XL","XX","IX","VI","IV","II"] pri_lis4 = ["M","D","C","L","X","V","I"] def trans(x): lis = [] x2 = copy.deepcopy(x) for i in pri_lis: if x2[0:4] == i: lis.append(pri_dic[i]) x2 = x2[4:] for i in pri_lis2: if x2[0:3] == i: lis.append(pri_dic[i]) x2 = x2[3:] for i in pri_lis3: if x2[0:2] == i: lis.append(pri_dic[i]) x2 = x2[2:] for i in pri_lis4: if x2[0:1] == i: lis.append(pri_dic[i]) x2 = x2[1:] return sum(lis) nums2 = [] for i in range(n): nums2.append(trans(nums[i])) nums3 = sum(nums2) def get_key(va): return [k for k, v in pri_dic.items() if v == va][0] nums4 = [] def trans2(x): y = str(x) l = len(y) for i in range(l): a = y[-1-i] nums4.append(get_key(int(a)*(10**i))) nums5 = reversed(nums4) return ''.join(nums5) if nums3 <= 3999: print(trans2(nums3)) else: print("ERROR")