[PYTHON] Codeforces Beta Round # 2

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

Codeforces Beta Round # 13
Codeforces Beta Round # 1
Codeforces Beta Round # 2
Educational Codeforces Round 87
Codeforces Round # 643 (Div. 2) Review
Codeforces Round # 679 (Div. 2) Review (10/25)
Codeforces Round # 658 (Div. 2) Bacha Review (7/29)
Codeforces Round # 654 (Div. 2) Bacha Review (8/18)
Codeforces Round # 594 (Div. 2) Bacha Review (10/29)
Educational Codeforces Round 93 Bacha Review (8/17)
Codeforces Round # 609 (Div. 2) Bacha Review (10/8)
Educational Codeforces Round 94 Bacha Review (9/3)
Educational Codeforces Round 91 Bacha Review (7/28)
Codeforces Round # 597 (Div. 2) Bacha Review (10/27)
Codeforces Round # 666 (Div. 2) Bacha Review (9/2)
Codeforces Round # 651 (Div. 2) Bacha Review (8/20)
Codeforces Round # 659 (Div. 2) Bacha Review (8/5)
Codeforces Round # 610 (Div. 2) Bacha Review (10/5)
Codeforces Round # 479 (Div. 3) Bacha Review (9/25)
Educational Codeforces Round 88 Bacha Review (8/4)
Codeforces Round # 600 (Div. 2) Bacha Review (10/21)
Codeforces Round # 481 (Div. 3) Bacha Review (9/24)
Codeforces Round # 639 (Div. 2) Bacha Review (9/4)
Codeforces Round # 612 (Div. 2) Bacha Review (10/2)
Educational Codeforces Round 86 Bacha Review (9/17)
Codeforces Round # 652 (Div. 2) Bacha Review (8/24)
Codeforces Round # 673 (Div. 2) Bacha Review (10/22)
Codeforces Round # 606 (Div. 3) Bacha Review (10/13)
Codeforces Round # 613 (Div. 2) Bacha Review (10/1)
Codeforces Round # 665 (Div. 2) Bacha Review (8/23)
Codeforces Round # 592 (Div. 2) Bacha Review (11/03)
Codeforces Round # 618 (Div. 2) Bacha Review (9/26)
Codeforces Round # 648 (Div. 2) Bacha Review (9/5)
Codeforces Round # 676 (Div. 2) Bacha Review (10/31)
Codeforces Round # 675 (Div. 2) Bacha Review (10/30)
Codeforces Round # 671 (Div. 2) Bacha Review (9/22)
Educational Codeforces Round 89 Bacha Review (9/8)
Codeforces Round # 669 (Div. 2) Bacha Review (9/9)
Codeforces Round # 672 (Div. 2) Bacha Review (10/16)
Codeforces Round # 638 (Div. 2) Bacha Review (9/16)
Codeforces Round # 663 (Div. 2) Bacha Review (8/13)
Educational Codeforces Round 92 Bacha Review (7/30)
Codeforces Round # 626 B. Count Subrectangles
Codeforces Round # 663 (Div. 2) Bacha Review (8/16)
Codeforces Round # 609 (Div. 2) Bacha Review (10/6)
Codeforces Round # 645 (Div. 2) Bacha Review (9/10)
Educational Codeforces Round 90 Bacha Review (8/19)
Codeforces Round # 664 (Div. 2) Bacha Review (8/13)
Codeforces Round # 660 (Div. 2) Bacha Review (8/4)
Codeforces Round # 609 (Div. 2) (up to B)