ps | |
---|---|
링크 | acmicpc.net/… |
출처 | BOJ |
문제 번호 | 10814 |
문제명 | 나이순 정렬 |
레벨 | 실버 5 |
분류 |
기초 |
시간복잡도 | O(nlogn) |
인풋사이즈 | n<=100,000 |
사용한 언어 | Python |
제출기록 | 37144KB / 148ms |
최고기록 | 116ms |
해결날짜 | 2021/08/22 |
"""Solution code for "BOJ 10814. 나이순 정렬".
- Problem link: https://www.acmicpc.net/problem/10814
- Solution link: http://www.teferi.net/ps/problems/boj/10814
"""
import sys
def main():
N = int(sys.stdin.readline())
lines = [sys.stdin.readline() for _ in range(N)]
print(''.join(sorted(lines, key=lambda x: int(x.split()[0]))))
if __name__ == '__main__':
main()
"""Solution code for "BOJ 10814. 나이순 정렬".
- Problem link: https://www.acmicpc.net/problem/10814
- Solution link: http://www.teferi.net/ps/problems/boj/10814
"""
import sys
MAX_AGE = 200
def main():
N = int(sys.stdin.readline())
buckets = [[] for _ in range(MAX_AGE + 1)]
for _ in range(N):
line = sys.stdin.readline()
buckets[int(line.split()[0])].append(line)
print(''.join(''.join(bucket) for bucket in buckets))
if __name__ == '__main__':
main()