This is the 10th day of my participation in the November Gwen Challenge. Check out the event details: The last Gwen Challenge 2021

【PTA group Program Design Ladder Competition 】

L1-055 who is the winner (10) the Go | Golang

An entertainment program of a TV station has a performance evaluation link. Each time two artists are arranged to perform, and their winners and losers are jointly decided by the audience voting and three judges voting. The rules are: if an artist has the highest number of votes from the audience and is recognized by at least one judge, the artist wins; Or an artist with a low number of audience votes, but the recognition of all judges, can also win. The show guarantees an odd number of viewers to vote, so there is no tie. Who is the winner?

Input format:

Input the first line to give two positive integers Pa and Pb not exceeding 1000, respectively, are the audience votes received by artist A and artist B. They guarantee that these two numbers are not equal. The second line then gives the results of the three judges’ votes. The number 0 represents a vote for A, and the number 1 represents a vote for B, separated by a space.

Output format:

Output the winner in the following format:

The winner is x: P1 + P2
Copy the code

Where X is the letter for the winner, P1 is the number of votes the winner gets from the audience, and P2 is the number of votes the winner gets from the judges.

Input Example 1:

327 129
1 0 1
Copy the code

No blank line at the end

Example 1:

The winner is a: 327 + 1
Copy the code

No blank line at the end

Ideas:

The basic judgment conditions are discussed separately.

The code is as follows:

package main

import "fmt"

func main(a) {
	var a,b,c,d,e int
	_, _ = fmt.Scan(&a, &b)
	_, _ = fmt.Scan(&c, &d, &e)
	if c+d+e == 0 {
		fmt.Printf("The winner is a: %d + %d",a,0)
		return
	}
	if c+d+e == 3 {
		fmt.Printf("The winner is b: %d + %d",b,3)
		return
	}
	if a+3-(c+d+e) > b+c+d+e {
		fmt.Printf("The winner is a: %d + %d",a,3-(c+d+e))
	}
	if a+3-(c+d+e) < b+c+d+e {
		fmt.Printf("The winner is a: %d + %d",b, c+d+e)
	}
}

Copy the code