목차

트리플 소트

ps
링크acmicpc.net/…
출처BOJ
문제 번호20309
문제명트리플 소트
레벨실버 3
분류

불변량

시간복잡도O(n)
인풋사이즈n<=300000
사용한 언어Python 3.13
제출기록62196KB / 116ms
최고기록112ms
해결날짜2025/11/13

풀이

코드

"""Solution code for "BOJ 20309. 트리플 소트".

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

Tags: [invariant]
"""


def main():
    _N = int(input())
    arr = [int(x) for x in input().split()]
    is_sortable = all(x % 2 == 1 for x in arr[::2])
    print('YES' if is_sortable else 'NO')


if __name__ == '__main__':
    main()