結果

問題 No.1906 Twinkle Town
ユーザー googol_S0
提出日時 2022-04-15 22:19:18
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 475 bytes
コンパイル時間 283 ms
コンパイル使用メモリ 82,448 KB
実行使用メモリ 113,156 KB
最終ジャッジ日時 2024-12-25 01:09:59
合計ジャッジ時間 9,776 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other WA * 20 RE * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

C=0
for t in range(int(input())):
  N=int(input())
  C+=N*N
  if C>=10000000:
    assert(0)
  A=[0]+sorted(map(int,input().split()))
  B=[]
  for i in range(N,0,-1):
    B.append(A[i]-A[i-1])
  B=B[::-1]
  K=(N+1)//2
  DP=[[0]*(K+1) for i in range(N+1)]
  for i in range(N):
    for j in range(K+1):
      DP[i+1][j]=max(DP[i+1][j],DP[i][j])
      if j<K:
        DP[i+1][j+1]=max(DP[i+1][j+1],DP[i][j]+B[i])
    for j in range((i+1)//2):
      DP[i+1][j]=0
  print(DP[N][K])
0