結果
問題 |
No.2909 Imaginary Summer
|
ユーザー |
|
提出日時 | 2024-10-02 22:42:24 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 2,380 ms / 6,000 ms |
コード長 | 478 bytes |
コンパイル時間 | 237 ms |
コンパイル使用メモリ | 12,416 KB |
実行使用メモリ | 97,096 KB |
最終ジャッジ日時 | 2024-10-02 22:43:44 |
合計ジャッジ時間 | 78,804 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
外部呼び出し有り |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 37 |
ソースコード
from scipy.spatial import KDTree n, m, k = map(int, input().split()) p, q = map(int, input().split()) station = [tuple(map(int, input().split())) for _ in range(n)] target = [tuple(map(int, input().split())) for _ in range(k)] tree = KDTree(station) d = tree.query((p, q), 1)[0] dists = tree.query(target, 1)[0] ans = 0 for (x, y), res in zip(target, dists): dx = x - p dy = y - q dist = min(d + res, (dx * dx + dy * dy) ** 0.5) ans += dist print(2 * ans)