← Back to List

31496번: 자작나무가 없소~ ↗

Solutions

Python 3
657 B | 657 chars
import sys
from math import sqrt, pi, sin, factorial, ceil, floor
from datetime import datetime, timedelta
sys.setrecursionlimit(10**7)

BLANK = " "

#inp = input
inp = lambda : sys.stdin.readline().rstrip()
mii = lambda x = BLANK : [*map(int,inp().split(x))]
mfi = lambda x = BLANK : [*map(float,inp().split(x))]
ii = lambda : int(inp())
fi = lambda : float(inp())
p = print


def solve():
  n, s = inp().split()
  
  ans = 0
  
  for i in range(int(n)):
    k, cnt = inp().split()
    l = k.split("_")
    cnt = int(cnt)
    
    if s in l:
      ans += cnt
  p(ans)
  
  
if __name__ == "__main__":
  tc = 1

  for t in range(1, tc+1):
    ret = solve()