結果
問題 |
No.518 ローマ数字の和
|
ユーザー |
![]() |
提出日時 | 2017-06-01 23:26:26 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,225 bytes |
コンパイル時間 | 76 ms |
コンパイル使用メモリ | 12,800 KB |
実行使用メモリ | 11,648 KB |
最終ジャッジ日時 | 2024-09-21 21:43:29 |
合計ジャッジ時間 | 1,565 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 WA * 2 |
other | AC * 5 WA * 14 |
ソースコード
# coding: utf-8 import array, bisect, collections, copy, heapq, itertools, math, random, re, string, sys, time sys.setrecursionlimit(10 ** 7) INF = 10 ** 20 MOD = 10 ** 9 + 7 def II(): return int(input()) def ILI(): return list(map(int, input().split())) def IAI(LINE): return [ILI() for __ in range(LINE)] def IDI(): return {key: value for key, value in ILI()} roman_table = [ ("M", 1000), ("CM", 900), ("D", 500), ("CD", 400), ("C", 100), ("XC", 90), ("L", 50), ("XL", 40), ("X", 10), ("IX", 9), ("IV", 4), ("I", 1), ] def roman_to_int(str): ret_num = 0 for c, n in roman_table: while str.startswith(c): str = str[len(c):] ret_num += n return ret_num def int_to_roman(num): res = "" for s, v in roman_table: d, num = divmod(num, v) res += d * s return res def read(): N = II() R = list(map(str, input().split())) return (N, R) def solve(N, R): num_sum = sum(map(roman_to_int, R)) if num_sum >= 4000: return "ERROR" else: return int_to_roman(num_sum) def main(): params = read() print(solve(*params)) if __name__ == "__main__": main()