The problem is from codeforces: http://www.codeforces.com/problemset/problem/237/A
If there are two or more people coming to buy at the same time, and there is no enough cashers, just simply increase the answer.
The solution in Python gives the idea.
#!/usr/bin/env python # https://helloacm.com n = int(raw_input()) a = dict() ans = 1 xx = 1 for x in xrange(n): h, s = map(int, raw_input().strip().split(" ")) t = h * 60 + s if a.has_key(t): ans += 1 if ans > xx: xx = ans else: a[t] = True ans = 1 print xx
The shorter implementation can be given in ‘Python’ way.
c={} for _ in range(input()): s = raw_input() c[s] = (c.get(s) or 0) + 1 print max(c.values())
Or
n = input() a = [0]*9999 for i in range(n): x, y = map(int, raw_input().split()) a[60*x+y] += 1; print max(a)
Or
n = int(raw_input()) cash = {} for i in range(n): key = raw_input() if (key in cash): cash[key] += 1 else: cash[key] = 1 max = 0 for key in cash: if (cash[key] > max): max = cash[key] print max
–EOF (The Ultimate Computing & Technology Blog) —
GD Star Rating
loading...
268 wordsloading...
Last Post: BrainFuck Interpreter, C# Console Application
Next Post: Codeforces: 236A. Boy or Girl ?