結果
| 問題 |
No.609 Noelちゃんと星々
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-12-09 00:42:33 |
| 言語 | Python2 (2.7.18) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 513 bytes |
| コンパイル時間 | 420 ms |
| コンパイル使用メモリ | 6,912 KB |
| 実行使用メモリ | 26,528 KB |
| 最終ジャッジ日時 | 2024-11-29 20:50:13 |
| 合計ジャッジ時間 | 59,991 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | WA * 2 RE * 7 TLE * 16 |
ソースコード
#!/usr/bin/python2
# -*- coding: utf-8 -*-
# †
n = int(raw_input())
y = map(float, raw_input().split())
# 高さを決めたときの、距離の総和を求める
def calc(height):
res = 0
for i in xrange(n):
res += abs(height - y[i])
return res
lo, hi = 0, 10**20
for _ in xrange(200):
m1 = (lo + lo + hi) / 3.
m2 = (lo + hi + hi) / 3.
if calc(m1) < calc(m2):
hi = m2
else:
lo = m1
res = calc(lo)
ires = int(res)
assert abs(res - ires) < 1e-9
print ires