사용자 도구

사이트 도구


ps:problems:boj:33392

Simple Game

ps
링크acmicpc.net/…
출처BOJ
문제 번호33392
문제명Simple Game
레벨플래티넘 5
분류

게임 이론

시간복잡도O(T*n)
인풋사이즈T*n <= 250000
사용한 언어Python 3.13
제출기록48640KB / 220ms
최고기록220ms
해결날짜2025/08/21

풀이

  • 물고기 게임와 동일한 세팅의 문제이다. 풀이는 그쪽을 참고.

코드

"""Solution code for "BOJ 33392. Simple Game".

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

Tags: [game theory]
"""

import sys
from teflib import psutils


@psutils.run_n_times
def main():
    n = int(sys.stdin.readline())
    a1 = [int(x) for x in sys.stdin.readline().split()]
    a2 = [int(x) for x in sys.stdin.readline().split()]

    if n % 2 == 1:
        score1 = sum(a1[: n // 2]) + sum(a2[: n // 2])
        score2 = min(sum(a1), score1 + a1[n // 2] + a2[n // 2])
        print(max(score1, score2))
    else:
        score1 = sum(a1[: n // 2]) + sum(a2[: n // 2])
        score2a = max(score1, sum(a1))
        score2b = score1 + a1[n // 2] + a2[n // 2]
        score2 = min(score2a, score2b)
        print(max(score1, score2))


if __name__ == '__main__':
    main()

토론

댓글을 입력하세요:
P W M G M
 
ps/problems/boj/33392.txt · 마지막으로 수정됨: 2025/08/21 05:14 저자 teferi