結果

問題 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
純コード判定しない問題か言語
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
59,568 KB
testcase_01 AC 42 ms
59,696 KB
testcase_02 AC 42 ms
61,840 KB
testcase_03 AC 43 ms
61,840 KB
testcase_04 AC 46 ms
61,840 KB
testcase_05 AC 42 ms
59,696 KB
testcase_06 AC 42 ms
61,840 KB
testcase_07 AC 43 ms
61,840 KB
testcase_08 AC 43 ms
61,840 KB
testcase_09 AC 43 ms
61,840 KB
testcase_10 AC 42 ms
61,840 KB
testcase_11 AC 42 ms
61,836 KB
testcase_12 AC 41 ms
61,836 KB
testcase_13 AC 64 ms
61,836 KB
testcase_14 AC 41 ms
61,840 KB
testcase_15 AC 42 ms
61,840 KB
testcase_16 AC 42 ms
61,836 KB
testcase_17 AC 41 ms
61,836 KB
testcase_18 AC 42 ms
61,840 KB
testcase_19 AC 40 ms
59,568 KB
testcase_20 AC 43 ms
61,840 KB
testcase_21 AC 42 ms
61,840 KB
testcase_22 AC 42 ms
59,568 KB
testcase_23 AC 42 ms
59,568 KB
testcase_24 AC 41 ms
59,568 KB
testcase_25 AC 43 ms
61,840 KB
testcase_26 AC 42 ms
61,836 KB
testcase_27 AC 44 ms
61,840 KB
testcase_28 AC 40 ms
59,568 KB
testcase_29 AC 40 ms
59,568 KB
testcase_30 AC 41 ms
59,568 KB
testcase_31 AC 45 ms
61,840 KB
testcase_32 AC 42 ms
61,840 KB
testcase_33 AC 43 ms
61,840 KB
testcase_34 AC 42 ms
61,840 KB
testcase_35 AC 44 ms
61,836 KB
testcase_36 AC 43 ms
61,836 KB
testcase_37 AC 41 ms
59,696 KB
testcase_38 AC 42 ms
61,840 KB
testcase_39 AC 42 ms
61,840 KB
testcase_40 AC 41 ms
61,840 KB
testcase_41 AC 42 ms
61,840 KB
testcase_42 AC 43 ms
61,836 KB
testcase_43 AC 43 ms
61,840 KB
testcase_44 AC 42 ms
61,840 KB
testcase_45 AC 43 ms
61,840 KB
testcase_46 AC 41 ms
61,840 KB
testcase_47 AC 41 ms
61,840 KB
testcase_48 AC 41 ms
59,568 KB
testcase_49 AC 42 ms
61,840 KB
権限があれば一括ダウンロードができます

ソースコード

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