1 ‘‘‘def count_lead(first, second): 2 if first > second: 3 return 1, first - second 4 elif first == second: # 题目中没有说明相等的情况 5 return 0, 0 6 else: 7 return 2, second - first‘‘‘ 8 9 10 def main(): 11 n = int(raw_input()) 12 lead = 0 13 winner = 0 # 有些初始值不放置,判断不成立而输出时,为空了就 14 num1 = 0 15 num2 = 0 16 while n > 0: 17 first, second = map(int, raw_input().split()) 18 if abs(first-second) > lead: # 绝对值函数 19 lead = abs(first-second) 20 num1 += first 21 num2 += second 22 n -= 1 23 24 print num1, num2 25 if num1 > num2: # 这个地方题目有歧义,总分赢还是分局赢 26 winner = 1 27 else: 28 winner = 2 29 30 print "%d %d" % (winner, lead) # 注意满足题目输出的的格式要求,int整数 31 32 main()
http://www.codechef.com/problems/TLG
学习
时间: 2024-11-06 09:33:53