結果
問題 |
No.467 隠されていたゲーム
|
ユーザー |
![]() |
提出日時 | 2025-03-26 15:47:17 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,079 bytes |
コンパイル時間 | 235 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 52,480 KB |
最終ジャッジ日時 | 2025-03-26 15:48:22 |
合計ジャッジ時間 | 2,335 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 WA * 7 |
ソースコード
def main(): import sys input = sys.stdin.read().split() idx = 0 n = int(input[idx]) idx += 1 d_list = list(map(int, input[idx:idx + n])) idx += n x = int(input[idx]) y = int(input[idx + 1]) D = max(abs(x), abs(y)) if D == 0: print(0) return max_d = max(d_list) has_even = any(d % 2 == 0 for d in d_list) has_odd = any(d % 2 == 1 for d in d_list) mixed = has_even and has_odd all_even = has_even and not has_odd all_odd = has_odd and not has_even k_min = (D + max_d - 1) // max_d # ceil(D / max_d) # Check up to k_min + 4 to handle cases where the minimal k is near the boundary for k in range(k_min, k_min + 4 + 1): sum_max = k * max_d if sum_max < D: continue ok = False if mixed: ok = True elif all_even: ok = (D % 2 == 0) else: # all_odd ok = (k % 2 == D % 2) if ok: print(k) return print(-1) if __name__ == "__main__": main()