結果
| 問題 |
No.5020 Averaging
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-02-25 15:25:09 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,400 bytes |
| コンパイル時間 | 172 ms |
| コンパイル使用メモリ | 81,700 KB |
| 実行使用メモリ | 78,412 KB |
| スコア | 0 |
| 最終ジャッジ日時 | 2024-02-25 15:26:00 |
| 合計ジャッジ時間 | 50,285 ms |
|
ジャッジサーバーID (参考情報) |
judge13 / judge12 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | WA * 50 |
ソースコード
#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], ans[i+M]])
print(len(l))
for x in l:
print(*x)
stdout(ans)