목차

크리스 마틴

ps
링크acmicpc.net/…
출처BOJ
문제 번호7977
문제명크리스 마틴
레벨골드 3
분류

LCS

시간복잡도O(n)
인풋사이즈n<=10000
사용한 언어Python 3.13
제출기록32412KB / 28ms
최고기록28ms
해결날짜2026/02/07

풀이

코드

"""Solution code for "BOJ 7977. 크리스 마틴".

- Problem link: https://www.acmicpc.net/problem/7977
- Solution link: http://www.teferi.net/ps/problems/boj/7977

Tags: [lcs]
"""


def main():
    n = int(input())
    dna = input()
    fewest_char = min('ACGT', key=dna.count)
    print(dna.count(fewest_char))
    print(fewest_char * n)


if __name__ == '__main__':
    main()