結果

問題 No.5021 Addition Pyramid
ユーザー june19312
提出日時 2025-02-25 22:26:28
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,945 ms / 2,000 ms
コード長 1,090 bytes
コンパイル時間 325 ms
コンパイル使用メモリ 82,120 KB
実行使用メモリ 79,176 KB
スコア 34,021,075
最終ジャッジ日時 2025-02-25 22:28:10
合計ジャッジ時間 101,337 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
純コード判定しない問題か言語
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 50
権限があれば一括ダウンロードができます

ソースコード

diff #

from time import *
start_time = time()
from random import *
from sys import *
input = stdin.readline
MAX = 100000000

N = int(input())
score = 10**10

# 誤差関数
def error(a, b):
    return min(abs(a - b), MAX - abs(a - b))

tmp = []
for i in range(N):
    tmp.append(list(map(int,input().split())))

ans = []
for i in range(N):
    ans.append([0]*(i+1))

ans[-1] = tmp[-1][:]

def build():
    diff = 0

    for i in range(N):
        diff = max(diff,error(ans[-1][i],tmp[-1][i]))
    
    for i in range(N-2,-1,-1):
        for j in range(i+1):
            ans[i][j] = (ans[i+1][j] + ans[i+1][j+1])%100000000
            diff = max(diff,error(ans[i][j],tmp[i][j]))

    return diff

score = build()

cnt = 0
while time()-start_time < 1.9:
    L = randint(0,N)
    R = randint(0,N)

    if L == R:
        continue
    elif L > R:
        L,R = R,L

    before = ans[-1][:]

    for j in range(L,R):
        ans[-1][j] = randint(0,99999999)

    nexscore = build()

    if nexscore < score:
        score = nexscore
        cnt += 1
    else:
        ans[-1] = before

print(*ans[-1])
0