結果

問題 No.2078 魔抜けなパープル
ユーザー flygonflygon
提出日時 2022-09-25 22:21:37
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 409 bytes
コンパイル時間 289 ms
コンパイル使用メモリ 87,176 KB
実行使用メモリ 86,212 KB
最終ジャッジ日時 2023-08-24 02:20:07
合計ジャッジ時間 2,923 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 99 ms
77,320 KB
testcase_01 AC 276 ms
85,712 KB
testcase_02 WA -
testcase_03 AC 248 ms
84,256 KB
testcase_04 AC 212 ms
81,860 KB
testcase_05 AC 212 ms
81,948 KB
testcase_06 AC 363 ms
86,212 KB
testcase_07 AC 157 ms
81,700 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from heapq import heappop
t = int(input())
for  i in range(t):
  x,a = map(int,input().split())
  INF = 10**18
  dp = [INF]*(a+1)
  dp[0] = 0
  ks = []
  border = int(x**0.5)+1
  for i in range(border-5, border+5):
    if i <= 0: continue
    ks.append([i,i*i+x])
  for i in range(1,a+1):
    dp[i] = i*i+x
    for j,jc in ks:
      if j > i: break
      dp[i] = min(dp[i], dp[i-j]+ jc)
  print(dp[-1])


    
0