ํฐ์คํ ๋ฆฌ ๋ทฐ
๐ฉ๐ป๐ป ๋ฌธ์
โ๐ป ํ์ด
๐จ Go
// https://www.acmicpc.net/problem/2303
package main
import (
"bufio"
"fmt"
"os"
)
func main() {
reader := bufio.NewReader(os.Stdin)
writer := bufio.NewWriter(os.Stdout)
defer writer.Flush()
var n int
fmt.Fscanln(reader, &n)
var cards = make([][]int, n)
for i := 0; i < n; i++ {
cards[i] = make([]int, 5)
for j := 0; j < 5; j++ {
fmt.Fscanf(reader, "%d ", &cards[i][j])
}
}
fmt.Fprintln(writer, getWinner(cards))
}
func getWinner(cards [][]int) int {
var maxSum, winner int
var sumOne, sumTwo, sumThree int
for i := 0; i < len(cards); i++ {
for j := 0; j < 5; j++ {
sumOne = cards[i][j]
for k := j + 1; k < 5; k++ {
sumTwo = sumOne + cards[i][k]
for l := k + 1; l < 5; l++ {
sumThree = sumTwo + cards[i][l]
}
if maxSum <= sumThree%10 {
maxSum = sumThree % 10
winner = i + 1
}
}
}
}
return winner
}
๐จ Python3
# https://www.acmicpc.net/problem/2303
import sys
def get_winnder(cards):
max_sum, winner = 0, 0
sum_one, sum_two, sum_three = 0, 0, 0
for i in range(len(cards)):
for j in range(5):
sum_one = cards[i][j]
for k in range(j+1, 5):
sum_two = sum_one + cards[i][k]
for l in range(k+1, 5):
sum_three = sum_two + cards[i][l]
if max_sum <= sum_three % 10:
max_sum = sum_three % 10
winner = i + 1
return winner
if __name__ == "__main__":
n = int(sys.stdin.readline())
cards = []
for i in range(n):
cards.append(list(map(int, sys.stdin.readline().split())))
print(get_winnder(cards))
728x90
'dev > algorithm' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
BOJ / 1158๋ฒ / ์์ธํธ์ค ๋ฌธ์ [Go][Python3] (0) | 2021.01.31 |
---|---|
BOJ / 5568๋ฒ / ์นด๋ ๋๊ธฐ [Go][Python3] (0) | 2021.01.30 |
BOJ / 2635๋ฒ / ์ ์ด์ด๊ฐ๊ธฐ [Go][Python3] (0) | 2021.01.28 |
BOJ / 14916๋ฒ / ๊ฑฐ์ค๋ฆ ๋ [Go][Python3] (0) | 2021.01.27 |
BOJ / 2422๋ฒ / ํ์ค์ ์ด ์ดํ๋ฆฌ์์ ๊ฐ์ ์์ด์คํฌ๋ฆผ์ ์ฌ๋จน๋๋ฐ [Go][Python3] (0) | 2021.01.26 |
๋๊ธ
๊ธ ๋ณด๊ดํจ
์ต๊ทผ์ ๋ฌ๋ฆฐ ๋๊ธ
TAG
- python3
- ๋ธ๋ฃจํธํฌ์ค
- ๋งฅ๋ถํ๋ก
- ๋งฅ๋ถ ์ ๊ทธ๋ ์ด๋
- Golang
- ์๋ฐ
- BFS
- dp
- dfs
- ์ด๋ถํ์
- ํ
- ๋ฐฑ์ค
- baekjoon
- ์๊ณ ๋ฆฌ์ฆ
- go
- AWS
- ๋ชฝ๊ณ ๋๋น
- MongoDB
- ํ๋ก์ด๋์์ฌ
- ๋งฅ๋ถ
- Macbook pro 2012 mid 13
- ์คํ
- ๋ฐ๋
- BOJ
- ballet
- ๋ถํ ์ ๋ณต
- ์๊ฐ๊ต์ฒด
- ํด์๋งต
- Algorithm
- java
- Total
- Today
- Yesterday