第 10 測資點(10%): WA (line:1)
答案不正確
您的答案為: 10260 4 正確答案為: 2656 4
import sys, re
for line in sys.stdin:
n = int(line.replace('\n', ''))
m = re.split('\D+', input())
m = sorted(m)
m = m[:n]
result = {}
i = 0
while i < len(m):
count = m.count(m[i])
result[m[i]] = count
i += count
for x in list(result):
for y in list(result):
if result.get(x) and result[x] > result[y]:
del result[y]
for e in sorted(result.keys()):
print(e, result[e])
第 10 測資點(10%): WA (line:1)
答案不正確
您的答案為: 10260 4 正確答案為: 2656 4
import sys, re
for line in sys.stdin:
n = int(line.replace('\n', ''))
m = re.split('\D+', input())
m = sorted(m)
result = {}
i = 0
while i < len(m):
count = m.count(m[i])
result[m[i]] = count
i += count
for x in list(result):
for y in list(result):
if result.get(x) and result[x] > result[y]:
del result[y]
for e in sorted(result.keys()):
print(e, result[e])