結果

問題 No.1944 ∞
ユーザー lam6er
提出日時 2025-04-15 22:07:50
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,647 bytes
コンパイル時間 396 ms
コンパイル使用メモリ 81,952 KB
実行使用メモリ 102,572 KB
最終ジャッジ日時 2025-04-15 22:09:13
合計ジャッジ時間 3,057 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 26 WA * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

import math

def main():
    import sys
    input = sys.stdin.read().split()
    idx = 0
    N = int(input[idx]); idx +=1
    X = int(input[idx]); idx +=1
    Y = int(input[idx]); idx +=1
    R = list(map(int, input[idx:idx+N]))
    idx += N
    
    D = math.hypot(X, Y)
    sum_all = sum(R)
    if N == 0:
        print("No")
        return
    
    max_val = max(R)
    count_max = R.count(max_val)
    
    # Find second_max
    second_max = 0
    for x in R:
        if x != max_val and x > second_max:
            second_max = x
    
    possible = False
    for r_last in R:
        # Compute L_rest
        if r_last == max_val:
            if count_max > 1:
                L_rest = max_val
            else:
                L_rest = second_max
        else:
            L_rest = max_val
        
        sum_rest = sum_all - r_last
        min_prev = max(2 * L_rest - sum_rest, 0)
        max_prev = sum_rest
        
        S_min = max(0, min_prev - r_last)
        S_max = max_prev + r_last
        
        # Check case 1: D = S + r_last
        if D >= r_last:
            S = D - r_last
            if S_min <= S <= S_max:
                possible = True
                break
        
        # Check case 2: D = S - r_last (S = D + r_last)
        S = D + r_last
        if S_min <= S <= S_max:
            possible = True
            break
        
        # Check case 3: D = r_last - S (S = r_last - D)
        if r_last >= D:
            S = r_last - D
            if S_min <= S <= S_max:
                possible = True
                break
    
    print("Yes" if possible else "No")

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