結果
問題 | No.5004 Room Assignment |
ユーザー |
![]() |
提出日時 | 2021-12-01 00:53:07 |
言語 | PyPy3 (7.3.15) |
結果 |
RE
|
実行時間 | - |
コード長 | 713 bytes |
コンパイル時間 | 612 ms |
実行使用メモリ | 100,504 KB |
スコア | 0 |
平均クエリ数 | 7.01 |
最終ジャッジ日時 | 2021-12-01 00:53:33 |
合計ジャッジ時間 | 19,565 ms |
ジャッジサーバーID (参考情報) |
judge16 / judge10 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | RE * 100 |
ソースコード
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],idx[i+1])) now = nxt print(len(L),flush=True) for u,v in L: print(u,v,flush=True) p += n