結果

問題 No.1944 ∞
ユーザー gew1fw
提出日時 2025-06-12 18:19:30
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,603 bytes
コンパイル時間 150 ms
コンパイル使用メモリ 82,352 KB
実行使用メモリ 105,568 KB
最終ジャッジ日時 2025-06-12 18:19:46
合計ジャッジ時間 2,588 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 35 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

import math

def main():
    import sys
    input = sys.stdin.read
    data = input().split()
    
    N = int(data[0])
    X = int(data[1])
    Y = int(data[2])
    R = list(map(int, data[3:3+N]))
    
    if N == 1:
        L = math.hypot(X, Y)
        if abs(L - R[0]) < 1e-9:
            print("Yes")
        else:
            print("No")
        return
    
    sum_all = sum(R)
    sorted_R = sorted(R)
    max_val = sorted_R[-1]
    count_max = R.count(max_val)
    min_val = sorted_R[0]
    count_min = R.count(min_val)
    
    L = math.hypot(X, Y)
    
    for r_last in R:
        sum_rest = sum_all - r_last
        # Determine M (max of remaining)
        if r_last == max_val:
            if count_max > 1:
                M = max_val
            else:
                # Find the new max after removing one max_val
                M = sorted_R[-2] if len(sorted_R) > 1 else 0
        else:
            M = max_val
        
        # Determine R_first (min of remaining)
        if r_last == min_val:
            if count_min > 1:
                R_first = min_val
            else:
                # Find the new min after removing one min_val
                R_first = sorted_R[1] if len(sorted_R) > 1 else 0
        else:
            R_first = min_val
        
        T = sum_rest - M
        min_d = abs(M - T)
        max_d = 2 * sum_rest - R_first + r_last
        
        lower = max(min_d, L - r_last)
        upper = min(max_d, L + r_last)
        
        if lower <= upper:
            print("Yes")
            return
    
    print("No")

if __name__ == "__main__":
    main()
0