結果
問題 | No.5008 [Cherry Alpha] Discrete Pendulum with Air Resistance |
ユーザー | kys |
提出日時 | 2022-10-14 23:12:41 |
言語 | PyPy3 (7.3.15) |
結果 |
RE
|
実行時間 | - |
コード長 | 4,832 bytes |
コンパイル時間 | 321 ms |
実行使用メモリ | 100,544 KB |
スコア | 0 |
最終ジャッジ日時 | 2022-10-14 23:13:29 |
合計ジャッジ時間 | 43,815 ms |
ジャッジサーバーID (参考情報) |
judge9 / judge8 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | RE | - |
testcase_01 | RE | - |
testcase_02 | RE | - |
testcase_03 | RE | - |
testcase_04 | RE | - |
testcase_05 | RE | - |
testcase_06 | RE | - |
testcase_07 | RE | - |
testcase_08 | RE | - |
testcase_09 | RE | - |
testcase_10 | RE | - |
testcase_11 | RE | - |
testcase_12 | RE | - |
testcase_13 | RE | - |
testcase_14 | RE | - |
testcase_15 | RE | - |
testcase_16 | RE | - |
testcase_17 | RE | - |
testcase_18 | RE | - |
testcase_19 | RE | - |
testcase_20 | RE | - |
testcase_21 | RE | - |
testcase_22 | RE | - |
testcase_23 | RE | - |
testcase_24 | RE | - |
testcase_25 | RE | - |
testcase_26 | RE | - |
testcase_27 | RE | - |
testcase_28 | RE | - |
testcase_29 | RE | - |
testcase_30 | RE | - |
testcase_31 | RE | - |
testcase_32 | RE | - |
testcase_33 | RE | - |
testcase_34 | RE | - |
testcase_35 | RE | - |
testcase_36 | RE | - |
testcase_37 | RE | - |
testcase_38 | RE | - |
testcase_39 | RE | - |
testcase_40 | RE | - |
testcase_41 | RE | - |
testcase_42 | RE | - |
testcase_43 | RE | - |
testcase_44 | RE | - |
testcase_45 | RE | - |
testcase_46 | RE | - |
testcase_47 | RE | - |
testcase_48 | RE | - |
testcase_49 | RE | - |
ソースコード
def main(): from sys import stdin, setrecursionlimit # setrecursionlimit(1000000) input = stdin.readline def iinput(): return int(input()) def sinput(): return input().rstrip() def i0input(): return int(input()) - 1 def linput(): return list(input().split()) def liinput(): return list(map(int, input().split())) def miinput(): return map(int, input().split()) def li0input(): return list(map(lambda x: int(x) - 1, input().split())) def mi0input(): return map(lambda x: int(x) - 1, input().split()) INF = 1000000000000000000 MOD = 1000000007 from itertools import combinations from math import sqrt def score(): X = [[] for _ in [0] * K] Y = [[] for _ in [0] * K] for b, m, e in zip(Bs, Ms, Es): start = 2 * b diff = 2 * e end = 2 * m last = (b - m) // e thr = start * (last + 1) - last * (last + 1) // 2 * diff for i, t in enumerate(T): if t <= thr: ok = MAXBE ng = -1 while ng + 1 < ok: ch = (ng + ok) // 2 if t < start * (ch + 1) - ch * (ch + 1) // 2 * diff: ng = ch else: ok = ch t -= start * ok - ok * (ok - 1) // 2 * diff if ok % 2: sgn = -1 else: sgn = 1 if t <= (start - ok * diff) // 2: X[i].append(sgn * t) else: X[i].append(sgn * (start - ok * diff - t)) else: t -= start * (last + 1) - last * (last + 1) // 2 * diff ok = last + t // end t %= end if ok % 2: sgn = -1 else: sgn = 1 if t <= end // 2: X[i].append(sgn * t) else: X[i].append(sgn * (end - t)) for i, t in enumerate(U): if t <= thr: ok = MAXBE ng = -1 while ng + 1 < ok: ch = (ng + ok) // 2 if t < start * (ch + 1) - ch * (ch + 1) // 2 * diff: ng = ch else: ok = ch t -= start * ok - ok * (ok - 1) // 2 * diff if ok % 2: sgn = -1 else: sgn = 1 if t <= (start - ok * diff) // 2: Y[i].append(sgn * t) else: Y[i].append(sgn * (start - ok * diff - t)) else: t -= start * (last + 1) - last * (last + 1) // 2 * diff ok = last + t // end t %= end if ok % 2: sgn = -1 else: sgn = 1 if t <= end // 2: Y[i].append(sgn * t) else: Y[i].append(sgn * (end - t)) tmp1 = [] for x in X: tmp1.append(0) for i in range(N): for j in range(i+1, N): tmp1[-1] += abs(x[i] - x[j]) / (Bs[i] + Bs[j]) tmp1[-1] *= 20000000 / N / (N - 1) tmp2 = [] for x in Y: tmp2.append(0) for i in range(N): for j in range(i+1, N): tmp2[-1] = max(tmp2[-1], abs(x[i] - x[j])) tmp2[-1] = 10000000 / sqrt(tmp2[-1] / 20 + 1) ans1 = sum(tmp1) / K ans2 = sum(tmp2) / K return ans1 * ans2 from random import randint N, K = miinput() MAXBE = 10**9 T = liinput() U = liinput() Bs = [randint(1, MAXBE) for _ in [0] * N] Ms = [] for b in Bs: Ms.append(randint(1, b)) Es = [randint(1, MAXBE) for _ in [0] * N] tmp_score = score() while time() - S < 1.8: idx = randint(1, N) newb = randint(1, MAXBE) newm = randint(1, newb) newe = randint(1, MAXBE) oldb = Bs[idx] oldm = Ms[idx] olde = Es[idx] Bs[idx], Ms[idx], Es[idx] = newb, newm, newe new_score = score() if new_score < tmp_score: Bs[idx], Ms[idx], Es[idx] = oldb, oldm, olde else: tmp_score = new_score for b, m, e in zip(Bs, Ms, Es): print(b, m, e) from time import time S = time() main()