ํฐ์คํ ๋ฆฌ ๋ทฐ
๐ฉ๐ป๐ป ๋ฌธ์
โ๐ป ํ์ด
๐จ Go
// https://www.acmicpc.net/problem/5635
package main
import (
"bufio"
"fmt"
"os"
"sort"
)
type studentFormat struct {
name string
day int
month int
year int
}
func main() {
reader := bufio.NewReader(os.Stdin)
writer := bufio.NewWriter(os.Stdout)
defer writer.Flush()
var n int
fmt.Fscanln(reader, &n)
var students []studentFormat
for i := 0; i < n; i++ {
student := studentFormat{}
fmt.Fscanln(reader, &student.name, &student.day, &student.month, &student.year)
students = append(students, student)
}
sort.Slice(students, func(i, j int) bool {
if students[i].year < students[j].year {
return true
} else if students[i].year == students[j].year {
if students[i].month < students[j].month {
return true
} else if students[i].month == students[j].month {
return students[i].day < students[j].day
}
}
return false
})
fmt.Fprintln(writer, students[len(students)-1].name)
fmt.Fprintln(writer, students[0].name)
}
๐จ Python3
# https://www.acmicpc.net/problem/5635
import sys
import datetime
if __name__ == "__main__":
n = int(sys.stdin.readline())
students = []
for i in range(n):
name, day, month, year = sys.stdin.readline().split()
birth = datetime.datetime(int(year), int(month), int(day))
students.append((birth, name))
students.sort()
print(students[-1][1])
print(students[0][1])
728x90
'dev > algorithm' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
BOJ / 1992๋ฒ / ์ฟผ๋ํธ๋ฆฌ [Go][Python3] (0) | 2020.12.29 |
---|---|
BOJ / 2630๋ฒ / ์์ข ์ด ๋ง๋ค๊ธฐ [Go][Python3] (0) | 2020.12.28 |
BOJ / 3182๋ฒ / ํ๋์ด๋ ๊ณต๋ถ๊ฐ ํ๊ธฐ ์ซ์ด! [Go][Python3] (0) | 2020.12.26 |
BOJ / 10708๋ฒ / ํฌ๋ฆฌ์ค๋ง์ค ํํฐ [Go][Python3] (0) | 2020.12.25 |
BOJ / 4573๋ฒ / Pizza Pricing [Go][Python3] (0) | 2020.12.22 |
๋๊ธ
๊ธ ๋ณด๊ดํจ
์ต๊ทผ์ ๋ฌ๋ฆฐ ๋๊ธ
TAG
- ํ
- ์๊ฐ๊ต์ฒด
- ์๊ณ ๋ฆฌ์ฆ
- baekjoon
- ๋ฐฑ์ค
- Macbook pro 2012 mid 13
- go
- ํด์๋งต
- ์๋ฐ
- BFS
- python3
- ๋ถํ ์ ๋ณต
- ๋ฐ๋
- ballet
- Golang
- ๋งฅ๋ถํ๋ก
- AWS
- ๋ธ๋ฃจํธํฌ์ค
- ๋งฅ๋ถ ์ ๊ทธ๋ ์ด๋
- ํ๋ก์ด๋์์ฌ
- Algorithm
- BOJ
- ๋ชฝ๊ณ ๋๋น
- dp
- ์ด๋ถํ์
- ๋งฅ๋ถ
- ์คํ
- dfs
- java
- MongoDB
- Total
- Today
- Yesterday