The Lead Game Add problem to Todo list Problem code: TLG

 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

The Lead Game Add problem to Todo list Problem code: TLG的相关文章

Turbo Sort Add problem to Todo list Problem code: TSORT

1 def heap_sort(ary): 2 n = len(ary) # 8 3 first = int(n / 2 - 1) # 3 4 for start in range(first, -1, -1): # 3~0 revese 5 max_heapify(ary, start, n - 1) # from start 6 for end in range(n - 1, 0, -1): 7 ary[end], ary[0] = ary[0], ary[end] 8 max_heapif

Holes in the text Add problem to Todo list Problem code: HOLES

1 import sys 2 3 4 def count_holes(letter): 5 hole_2 = ['A', 'D', 'O', 'P', 'Q', 'R'] 6 if letter == 'B': 7 return 2 8 elif letter in hole_2: 9 return 1 10 else: 11 return 0 12 13 14 def main(): 15 n = int(sys.stdin.readline()) 16 for t in sys.stdin:

hidden node and exposed node problem

Exposed node problem In wireless networks, theexposed node problem occurs when a node is prevented from sending packets to other nodes because of a neighboring transmitter. Consider an example of 4 nodes labeled R1, S1, S2, and R2, where the two rece

hdu 5349 MZL's simple problem

Problem Description A simple problem Problem Description You have a multiple set,and now there are three kinds of operations: 1 x : add number x to set 2 : delete the minimum number (if the set is empty now,then ignore it) 3 : query the maximum numbe

FZU 2215 Simple Polynomial Problem (多项式乘法 栈)

Problem 2215 Simple Polynomial Problem Time Limit: 1000 mSec    Memory Limit : 32768 KB Problem Description You are given an polynomial of x consisting of only addition marks, multiplication marks, brackets, single digit numbers, and of course the le

NCPC 2015 October 10, 2015 Problem D

NCPC 2015Problem DDisastrous DowntimeProblem ID: downtimeClaus Rebler, cc-by-saYou’re investigating what happened when one ofyour computer systems recently broke down. So faryou’ve concluded that the system was overloaded; itlooks like it couldn’t ha

FZU2176---easy problem (树链剖分)

http://acm.fzu.edu.cn/problem.php?pid=2176 Problem 2176 easy problem Accept: 9    Submit: 32Time Limit: 2000 mSec    Memory Limit : 32768 KB  Problem Description 给定一棵n个节点以1为根的树,初始每个节点的值为0,现在我们要在树上进行一些操作,操作有两种类型. 1 x val 表示对以x为根的子树的每个点进行加权操作(我们定义每个节点的

HDU 4971 A simple brute force problem.

A simple brute force problem. Time Limit: 1000ms Memory Limit: 65536KB This problem will be judged on HDU. Original ID: 497164-bit integer IO format: %I64d      Java class name: Main There's a company with several projects to be done. Finish a projec

MITx 6.00 Problem Set 3 hangman游戏

全部代码参见Github:https://github.com/pxjw/MITx-6.00.1-2-Problem-Set/tree/master/6.00.1x/proSet3 HANGMAN PART 1: IS THE WORD GUESSED? Please read the Hangman Introduction before starting this problem. The helper functions you will be creating in the next t