結果

問題 No.3531 Erase Pair
コンテスト
ユーザー detteiuu
提出日時 2026-05-04 23:19:37
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
WA  
実行時間 -
コード長 900 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 199 ms
コンパイル使用メモリ 85,704 KB
実行使用メモリ 83,208 KB
最終ジャッジ日時 2026-05-04 23:19:45
合計ジャッジ時間 6,815 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other WA * 50
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

from sys import stdin
input = stdin.readline
from math import gcd

def func(B):
    cnt = 0
    for i in range(len(B)):
        if i+1 < len(B) and B[i]+2 <= B[i+1]:
            return True
        if B[i] == 1: cnt += 1
    return cnt <= len(B)-cnt

for _ in range(int(input())):
    N = int(input())
    A = list(map(int, input().split()))

    L, R = [], []
    cnt = 0
    GCD = 0
    for a in A:
        GCD = gcd(GCD, abs(a))
        if a < 0:
            L.append(-a)
        elif a == 0:
            cnt += 1
        else:
            R.append(a)
    L.sort()
    R.sort()
    for i in range(len(L)):
        L[i] //= GCD
    for i in range(len(R)):
        R[i] //= GCD

    if 2 <= cnt or N%2 == 0 and cnt == 1:
        print("No")
        continue
    if cnt == 0:
        print("Yes")
        continue
    if not func(L) and not func(R):
        print("No")
    else:
        print("Yes")
0