結果
| 問題 |
No.1944 ∞
|
| コンテスト | |
| ユーザー |
gew1fw
|
| 提出日時 | 2025-06-12 14:17:06 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,774 bytes |
| コンパイル時間 | 180 ms |
| コンパイル使用メモリ | 83,032 KB |
| 実行使用メモリ | 124,544 KB |
| 最終ジャッジ日時 | 2025-06-12 14:17:15 |
| 合計ジャッジ時間 | 4,685 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 13 WA * 2 TLE * 1 -- * 20 |
ソースコード
import math
def main():
import sys
input = sys.stdin.read
data = input().split()
idx = 0
N = int(data[idx])
idx +=1
X = int(data[idx])
idx +=1
Y = int(data[idx])
idx +=1
R = list(map(int, data[idx:idx+N]))
idx += N
sum_R = sum(R)
D = math.hypot(X, Y)
# Handle N=1 case
if N == 1:
if (X == 0 and Y == 0) or (X**2 + Y**2 == R[0]**2):
print("Yes")
else:
print("No")
return
# For each possible R_last
for r_last in R:
# Compute the remaining elements
temp = [x for x in R if x != r_last]
if len(temp) == 0:
# All elements are r_last, but since N >=2, len(temp) can't be zero here
pass
else:
min_r_first = min(temp)
max_r_first = max(temp)
min_val = 2 * sum_R - max_r_first - r_last
max_val = 2 * sum_R - min_r_first - r_last
lower = D - r_last
upper = D + r_last
# Check overlap
if (max_val >= lower) and (min_val <= upper):
print("Yes")
return
# Check for the case where one R_last is the same as others, but minimal/maximal
# Also, when R_last is the minimal or maximal, but R_first can be arranged
# Additionally, check if the sum of all R's is sufficient
# But for the third sample, this approach fails
# So, perhaps another condition is needed
# The problem is that the initial approach doesn't consider that the sum can be arranged to have |S| >= D - R_last even if S_total is larger
# Thus, perhaps if sum_R >= D:
if sum_R >= D:
print("Yes")
return
print("No")
if __name__ == "__main__":
main()
gew1fw