結果
問題 | No.518 ローマ数字の和 |
ユーザー |
![]() |
提出日時 | 2018-08-04 10:47:13 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 570 bytes |
コンパイル時間 | 127 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 10,752 KB |
最終ジャッジ日時 | 2024-09-19 17:46:55 |
合計ジャッジ時間 | 1,470 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 16 WA * 3 |
ソースコード
n = int(input())dic = {"I":1,"V":5,"X":10,"L":50,"C":100,"D":500,"M":1000}lst = ["M","D","C","L","X","V","I"]num = list(input().split())ans = 0kaito = ""for i in num:tmp = [dic[i[0]]]for index in range(1,len(i)):x = dic[i[index]]if tmp[-1]<x:tmp[-1] = -tmp[-1]tmp.append(x)ans += sum(tmp)if ans>3999:print("ERROR")exit(0)for i,s in enumerate(lst):x = dic[s]y = ans//xif y==4:kaito += lst[i] + lst[i-1]elif y>0:kaito += lst[i]*yans -= x*yprint(kaito)