結果

問題 No.5020 Averaging
ユーザー ryo_nryo_n
提出日時 2024-02-25 15:47:23
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 64 ms / 1,000 ms
コード長 839 bytes
コンパイル時間 213 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 61,840 KB
スコア 18,955,542
最終ジャッジ日時 2024-02-25 15:47:29
合計ジャッジ時間 4,357 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
純コード判定しない問題か言語
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 50
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(10**8)

input = sys.stdin.readline

AVE = 5 * 10**17


N = int(input())
AB = [[int(x) for x in input().split()] for _ in range(N)]

# INF = float("inf")
INF = 1 << 70
operator = []
best_score = (INF, 0)

for _ in range(50):
    tmp_score = INF
    tmp_i = 0

    for i in range(N):
        a, b = AB[i]
        score = abs(AVE - (a + AB[0][0]) // 2) + abs(AVE - (b + AB[0][1]) // 2)
        if score < tmp_score:
            tmp_score = score
            tmp_i = i
    AB[0][0] = (AB[0][0] + AB[tmp_i][0]) // 2
    AB[0][1] = (AB[0][1] + AB[tmp_i][1]) // 2
    AB[tmp_i][0] = AB[0][0]
    AB[tmp_i][1] = AB[0][1]
    operator.append((1, tmp_i + 1))
    if best_score[0] > tmp_score:
        best_score = (tmp_score, len(operator))

print(best_score[1])
for op in operator[: best_score[1]]:
    print(*op)
0