Yes. I don't understand English at all.
A.Winner ・ Roughly It looks like a card game, but I can't understand it. .. ..
・ Something like a policy http://codeforces.com/blog/entry/109 1.First of all, we need to find the maximum score m at the end of the game. This can be done by emulating. After all rounds played just iterate over players and choose one with the maximum score. First of all, we need to find the maximum score m at the end of the game. This can be done by emulating. Repeat the players only after playing all rounds and choose the one with the highest score.
2.Second, we need to figure out the set of players who have maximum score at the end of the game. We can do this in the same way as calculating maximum score. Just iterate over players after all rounds played and store all players with score equal to m. Second, we need to keep track of the set of players with the highest scores at the end of the game. We can do this just as we would calculate the maximum score. It just repeats the players after playing all rounds and stores all players with a score equal to M.
3.And the last, we need to find a winner. To do this we will emulate the game one more time looking for player from the winner list with score not less m after some round. And finally, we need to find a winner. To do this we emulate once again the game looking for a player from a list of winners whose score is not small after some rounds.
http://codeforces.com/blog/entry/107 Simple problem, just code it. At the first pass calculate the sum of points for each player at game end. Let M be the maximum of these sums. At the second pass check every round. If current player X has not less than M points and his final score is equal to M then he is the winner. The following test illustrates that player could receive more than M points, then lose some and, finally, win. A simple problem, code it. The first pass calculates the total points for each player at the end of the game. M is the maximum value of these sums. Check all rounds on the second pass. If the current player's X has more points than M below and his final score is equal to M, then he is the winner. The next test shows that the player loses some and eventually wins when he receives more than M points. 2559602 This is a copy of daidailanlan.
a.py
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
l=[raw_input().split() for i in range(int(raw_input()))]
d={}
for x,y in l:
#The list is from 0th to x:Name y:Take out by points
#Addition of points with names that match the key values in the dictionary
#Originally it is an empty dictionary, so if there is no key match, the key value:Points will be added.
d[x]=d.get(x,0)+int(y)
#Find out the highest score
w=max(d.values())
##So far policy 1,Is it the second stage?
#And emulate the game again?
m={}
for x,y in l:
#Turn list l again and store in m
m[x]=m.get(x,0)+int(y)
#Above the highest score recorded in the previous for and Being the highest scorer in the previous tally?
if m[x]>=w and d[x] ==w:
#Print x that meets the victory conditions and exit with break
print x
break
python
l=[raw_input().split() for i in range(int(raw_input()))]
# [['mike', '3'], ['andrew', '5'], ['mike', '2']]
It seems that you can write the reception of n elements that are broken by in one line. If you want to for or while in several places depending on the number of elements in the list, it seems better to assign to n (generally n or something) according to the problem statement. You can use len (n) instead. ..
python
for x,y in l:
#x,If you check what value y is
#mike 3
#andrew 5
#mike 2
For x in l: does not just extract the name, but ['mike', '3'] appears.
B. The least round way Roughly the meaning Integers (not negative) are arranged in a square with n * n. ・ Start from the upper left and finish at the lower right Multiply all the numbers on the path and round off.
C. Commentator problem
Recommended Posts