結果
問題 | No.5020 Averaging |
ユーザー | uta |
提出日時 | 2024-02-25 13:37:45 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,243 bytes |
コンパイル時間 | 321 ms |
コンパイル使用メモリ | 81,700 KB |
実行使用メモリ | 80,052 KB |
スコア | 0 |
最終ジャッジ日時 | 2024-02-25 13:37:51 |
合計ジャッジ時間 | 6,746 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | WA | - |
testcase_37 | WA | - |
testcase_38 | WA | - |
testcase_39 | WA | - |
testcase_40 | WA | - |
testcase_41 | WA | - |
testcase_42 | WA | - |
testcase_43 | WA | - |
testcase_44 | WA | - |
testcase_45 | WA | - |
testcase_46 | WA | - |
testcase_47 | WA | - |
testcase_48 | WA | - |
testcase_49 | WA | - |
ソースコード
from dataclasses import dataclass, field # from sortedcontainers import SortedList, SortedDict, SortedSet from random import random, seed, randrange, choice, sample # from itertools import permutations, combinations, product from collections import deque, defaultdict, Counter # from heapq import heapify, heappush, heappop # from bisect import bisect_right, bisect_left from time import time import sys sys.setrecursionlimit(1000000) seed(0) def input(): return sys.stdin.buffer.readline().rstrip().decode(encoding='utf-8') try: isLocal except: isLocal = False if isLocal: input = line def randrange_s(stop:int)->int: return int(random()*stop) def randrange_ss(start:int, stop:int)->int: return int(random()*(stop-start)+start) class AHC(): def __init__(self): self.sTime = time() self.get_input() self.preprocessing() def get_input(self): self.N = int(input()) AB = [list(map(int, input().split())) for _ in range(self.N)] self.A, self.B = [], [] for a, b in AB: self.A.append(float(a)) self.B.append(float(b)) return def preprocessing(self): self.target = float(5*10**17) return def get_score(self): return max(abs(self.target-self.A[0]), abs(self.target-self.B[0])) def get_score2(self, a, b): return max(abs(self.target-a), abs(self.target-b)) def greedy(self): self.ans = [] self.cur = self.get_score() for _ in range(50): evaList = [] for i in range(1, self.N): a = (self.A[0]+self.A[i])/2 b = (self.B[0]+self.B[i])/2 evaList.append([self.get_score2(a, b), i]) nxt, v = min(evaList) if nxt>=self.cur: break self.cur = nxt self.ans.append(f"0 {v}") mean = (self.A[0]+self.A[v])/2 self.A[0] = mean self.A[v] = mean mean = (self.B[0]+self.B[v])/2 self.B[0] = mean self.B[v] = mean return def update(self): pass def output(self): print(len(self.ans)) print("\n".join(self.ans)) ahc = AHC() ahc.greedy() ahc.output()