ํฐ์คํ ๋ฆฌ ๋ทฐ
๐ฉ๐ป๐ป ๋ฌธ์
โ๐ป ํ์ด
๐จ 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
- ๋งฅ๋ถ ์ ๊ทธ๋ ์ด๋
- ๋ฐฑ์ค
- ์๊ณ ๋ฆฌ์ฆ
- ๋ฐ๋
- dfs
- AWS
- BFS
- java
- Macbook pro 2012 mid 13
- ํ
- python3
- ๋ชฝ๊ณ ๋๋น
- ์๋ฐ
- go
- ๋ถํ ์ ๋ณต
- Golang
- dp
- ํ๋ก์ด๋์์ฌ
- ballet
- ๋ธ๋ฃจํธํฌ์ค
- ๋งฅ๋ถ
- Algorithm
- BOJ
- ์คํ
- ์๊ฐ๊ต์ฒด
- ๋งฅ๋ถํ๋ก
- MongoDB
- baekjoon
- ํด์๋งต
- ์ด๋ถํ์
- Total
- Today
- Yesterday