結果

問題 No.5004 Room Assignment
ユーザー Eki1009
提出日時 2021-12-01 00:48:00
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 717 bytes
コンパイル時間 393 ms
実行使用メモリ 99,224 KB
スコア 0
平均クエリ数 2.41
最終ジャッジ日時 2021-12-01 00:48:26
合計ジャッジ時間 25,321 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other RE * 100
権限があれば一括ダウンロードができます

ソースコード

diff #

t,r = map(int,input().split())
p = 1
for _ in range(t):
    n,*S = map(int,input().split())
    S,idx = zip(*sorted([(s,i) for i,s in enumerate(S,p)]))
    dp = [-float("inf")]*(n+1)
    dp[0] = 0
    prev = [-1]*(n+1)
    for i in range(1,n+1):
        for j in range(1,5):
            if i-j >= 0:
                temp = dp[i-j]+j*(j-1)//2*(200-(S[i-1]-S[i-j])**2)
                if dp[i] < temp:
                    dp[i] = temp
                    prev[i] = i-j
    L = []
    now = n
    while now > 0:
        nxt = prev[now]
        for i in range(nxt,now-1):
            L.append((idx[i]+p,idx[i+1]+p))
        now = nxt
    print(len(L),flush=True)
    for u,v in L:
        print(u,v,flush=True)
    p += n
0