結果

問題 No.5020 Averaging
ユーザー Akijin_007Akijin_007
提出日時 2024-02-25 15:33:38
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 942 ms / 1,000 ms
コード長 1,509 bytes
コンパイル時間 345 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 78,284 KB
スコア 17,204,134
最終ジャッジ日時 2024-02-25 15:34:30
合計ジャッジ時間 50,110 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
純コード判定しない問題か言語
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 941 ms
77,796 KB
testcase_01 AC 941 ms
78,284 KB
testcase_02 AC 942 ms
77,772 KB
testcase_03 AC 942 ms
78,028 KB
testcase_04 AC 942 ms
77,800 KB
testcase_05 AC 941 ms
77,772 KB
testcase_06 AC 942 ms
77,800 KB
testcase_07 AC 940 ms
77,900 KB
testcase_08 AC 942 ms
77,772 KB
testcase_09 AC 941 ms
77,800 KB
testcase_10 AC 942 ms
78,028 KB
testcase_11 AC 942 ms
77,644 KB
testcase_12 AC 942 ms
77,644 KB
testcase_13 AC 941 ms
77,928 KB
testcase_14 AC 941 ms
77,932 KB
testcase_15 AC 942 ms
77,772 KB
testcase_16 AC 942 ms
77,644 KB
testcase_17 AC 941 ms
77,900 KB
testcase_18 AC 941 ms
77,772 KB
testcase_19 AC 941 ms
77,804 KB
testcase_20 AC 941 ms
77,772 KB
testcase_21 AC 942 ms
77,644 KB
testcase_22 AC 942 ms
77,644 KB
testcase_23 AC 942 ms
77,840 KB
testcase_24 AC 942 ms
77,672 KB
testcase_25 AC 941 ms
77,772 KB
testcase_26 AC 942 ms
77,800 KB
testcase_27 AC 941 ms
77,772 KB
testcase_28 AC 941 ms
77,800 KB
testcase_29 AC 942 ms
77,904 KB
testcase_30 AC 942 ms
77,928 KB
testcase_31 AC 942 ms
77,900 KB
testcase_32 AC 941 ms
77,772 KB
testcase_33 AC 942 ms
77,928 KB
testcase_34 AC 941 ms
77,900 KB
testcase_35 AC 941 ms
77,676 KB
testcase_36 AC 941 ms
77,672 KB
testcase_37 AC 940 ms
77,900 KB
testcase_38 AC 942 ms
77,772 KB
testcase_39 AC 941 ms
77,840 KB
testcase_40 AC 941 ms
78,028 KB
testcase_41 AC 942 ms
77,772 KB
testcase_42 AC 942 ms
77,772 KB
testcase_43 AC 941 ms
77,644 KB
testcase_44 AC 941 ms
77,644 KB
testcase_45 AC 942 ms
77,772 KB
testcase_46 AC 942 ms
77,388 KB
testcase_47 AC 940 ms
77,772 KB
testcase_48 AC 942 ms
77,928 KB
testcase_49 AC 941 ms
77,800 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#int(input())
#map(int, input().split())
#list(map(int, input().split()))

import time
import random
from math import floor, log10

N = int(input())
u = [0] * (2 * N)
for i in range(N):
    a, b = map(int, input().split())
    u[i] = a
    u[i+N] = b

ut = time.time()

def get_score(u):
    c = 5 * 10 ** 17
    v1 = abs(u[0] - c)
    v2 = abs(u[N] - c)
    s = floor(2 * 10 ** 6 - 10 ** 5 * log10(max(v1, v2) + 1))
    return s

M = 50
ans = [0] * (2 * M)

for i in range(2*M):
    ans[i] = random.randint(0, N-1)
# for i in range(10):
#     ans[i] = 0

def f(a):
    nu = list(u)
    for i in range(M):
        if a[i] == a[i+M]:
            continue
        x = a[i]
        y = a[i+M]
        nu[x] = floor((nu[x]+nu[y]) / 2)
        nu[y] = nu[x]
        nu[x+N] = floor((nu[x+N]+nu[y+N]) / 2)
        nu[y+N] = nu[y+N]

    return nu

nows = get_score(f(ans))
count = 0

while time.time() - ut < 0.9:
    nans = list(ans)
    t = random.randint(0, 2*M-1)
    n = random.randint(0, N-1)
    nans[t] = n
    s = get_score(f(nans))
    if s > nows:
        ans = list(nans)
        # print(s, nows)
        nows = s
        count += 1

fa = f(ans)
# print(count)
# print(fa[:3], fa[N:N+3])

def stdout(ans):
    l = []
    for i in range(M):
        if ans[i] == ans[i+M]:
            continue
        l.append([ans[i]+1, ans[i+M]+1])
    # f = open("out.txt", "w")
    # print(len(l), file=f)
    # for x in l:
    #     print(*x, file=f)
    print(len(l))
    for x in l:
        print(*x)

stdout(ans)
0