You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
딕셔너리에 나이를 key값으로 설정하고, 먼저 가입한 순서대로 value를 저장하기 위해 value는 array 타입으로 설정한다.
딕셔너리를 나이가 작은 순으로 정렬한 뒤 해당 나이의 회원을 가입한 순서대로 출력한다.
💬 풀이
import Foundation
func solution10814(){letn=Int(readLine()!)!
varojDict:[Int:[String]]=[:]
for _ in 1...n {leto=readLine()!.components(separatedBy:.whitespaces)letage=Int(o[0])!
if ojDict[age]==nil{ojDict[age]=[o[1]]}else{ojDict[age]?.append(o[1])}}
for i in ojDict.sorted(by:{ $0.key < $1.key }){
for j in i.value {print("\(i.key)\(j)")}}}solution10814()
The text was updated successfully, but these errors were encountered:
💬 문제
https://www.acmicpc.net/problem/10814
💬 Idea
💬 풀이
The text was updated successfully, but these errors were encountered: