λ¬Έμ
https://www.acmicpc.net/problem/11652
11652λ²: μΉ΄λ
μ€κ·λ μ«μ μΉ΄λ Nμ₯μ κ°μ§κ³ μλ€. μ«μ μΉ΄λμλ μ μκ° νλ μ νμλλ°, μ νμλ μλ -262λ³΄λ€ ν¬κ±°λ κ°κ³ , 262λ³΄λ€ μκ±°λ κ°λ€. μ€κ·κ° κ°μ§κ³ μλ μΉ΄λκ° μ£Όμ΄μ‘μ λ, κ°μ₯ λ§μ΄ κ°μ§
www.acmicpc.net
νμ΄
# λ°±μ€ 11652λ² λ¬Έμ - μΉ΄λ
n = int(input())
d = {}
for i in range(n):
card = int(input())
if card in d:
d[card] += 1
else:
d[card] = 1
result = sorted(d.items(), key = lambda x: (-x[1], x[0]))
print(result[0][0])
λμ λ리λ₯Ό μ¬μ©ν΄ ν΄κ²°νμλ€.
μΉ΄λ μ«μκ° μμ μμΌλ‘ μ λ ¬
'ποΈ Algorithm > π© λ°±μ€' μΉ΄ν κ³ λ¦¬μ λ€λ₯Έ κΈ
π© [λ°±μ€] [Python] [Gold4] 4179λ²_λΆ! (0) | 2023.04.11 |
---|---|
π© [λ°±μ€] [Python] [Silver5] 7785λ²_νμ¬μ μλ μ¬λ (0) | 2023.04.11 |
π© [λ°±μ€] [Python] [Silver5] 11004λ²_Kλ²μ§Έ μ (0) | 2023.04.09 |
π© [λ°±μ€] [Python] [Gold4] 15683λ²_κ°μ (0) | 2023.04.05 |
π© [λ°±μ€] [Python] [Silver3] 1213λ²_ν°λ¦°λ둬 λ§λ€κΈ° (0) | 2023.04.04 |