結果
問題 | No.5020 Averaging |
ユーザー |
![]() |
提出日時 | 2024-02-25 13:26:34 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 106 ms / 1,000 ms |
コード長 | 2,368 bytes |
コンパイル時間 | 288 ms |
コンパイル使用メモリ | 81,700 KB |
実行使用メモリ | 79,572 KB |
スコア | 18,955,542 |
最終ジャッジ日時 | 2024-02-25 13:26:42 |
合計ジャッジ時間 | 7,019 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge10 |
純コード判定しない問題か言語 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 50 |
ソースコード
import sysfrom collections import deque, defaultdictfrom itertools import (accumulate,product,permutations,combinations,combinations_with_replacement,)import mathfrom bisect import bisect_left, insort_left, bisect_right, insort_rightfrom pprint import pprintfrom heapq import heapify, heappop, heappushimport string# 小文字アルファベットのリストalph_s = list(string.ascii_lowercase)# 大文字アルファベットのリストalph_l = list(string.ascii_uppercase)# product : bit全探索 product(range(2),repeat=n)# permutations : 順列全探索# combinations : 組み合わせ(重複無し)# combinations_with_replacement : 組み合わせ(重複可)# from sortedcontainers import SortedSet, SortedList, SortedDictsys.setrecursionlimit(10**7)around4 = ((-1, 0), (1, 0), (0, -1), (0, 1)) # 上下左右around8 = ((-1, -1), (-1, 0), (-1, 1), (0, -1), (0, 1), (1, -1), (1, 0), (1, 1))inf = float("inf")mod = 998244353input = lambda: sys.stdin.readline().rstrip()P = lambda *x: print(*x)PY = lambda: print("Yes")PN = lambda: print("No")II = lambda: int(input())MII = lambda: map(int, input().split())LMII = lambda: list(map(int, input().split()))def dlist(*l, fill=0):if len(l) == 1:return [fill] * l[0]ll = l[1:]return [dlist(*ll, fill=fill) for _ in range(l[0])]# 入力def Input():global N, A, B, StSt = 5 * 10**17N = II()A = [0] * NB = [0] * Nfor i in range(N):A[i], B[i] = MII()def solve():ans = get_first_ans()return ansdef get_first_ans():ans_list = []for _ in range(50):score = abs(St - A[0]) + abs(St - B[0])tmp = scoreans = Nonefor j in range(1, 45):a, b = (A[0] + A[j]) // 2, (B[0] + B[j]) // 2if abs(St - a) + abs(St - b) < tmp:tmp = abs(St - a) + abs(St - b)ans = jif ans:ans_list.append([1, ans + 1])A[0], A[ans] = (A[0] + A[ans]) // 2, (A[0] + A[ans]) // 2B[0], B[ans] = (B[0] + B[ans]) // 2, (B[0] + B[ans]) // 2else:breakreturn ans_list# 出力def Output(ans):print(len(ans))for i in ans:print(*i)def main():Input()Output(solve())if __name__ == "__main__":main()