結果

問題 No.2330 Eat Slime
ユーザー tyawanmusityawanmusi
提出日時 2023-05-24 11:16:23
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,366 ms / 4,000 ms
コード長 878 bytes
コンパイル時間 113 ms
コンパイル使用メモリ 11,056 KB
実行使用メモリ 97,888 KB
最終ジャッジ日時 2023-08-25 03:10:08
合計ジャッジ時間 36,809 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 132 ms
29,668 KB
testcase_01 AC 132 ms
29,724 KB
testcase_02 AC 131 ms
29,736 KB
testcase_03 AC 131 ms
29,692 KB
testcase_04 AC 130 ms
29,636 KB
testcase_05 AC 135 ms
29,648 KB
testcase_06 AC 138 ms
29,804 KB
testcase_07 AC 1,061 ms
93,896 KB
testcase_08 AC 551 ms
66,580 KB
testcase_09 AC 1,095 ms
91,368 KB
testcase_10 AC 400 ms
38,316 KB
testcase_11 AC 485 ms
33,564 KB
testcase_12 AC 1,065 ms
92,396 KB
testcase_13 AC 938 ms
93,788 KB
testcase_14 AC 741 ms
38,016 KB
testcase_15 AC 885 ms
66,180 KB
testcase_16 AC 907 ms
91,652 KB
testcase_17 AC 1,352 ms
97,624 KB
testcase_18 AC 1,364 ms
97,716 KB
testcase_19 AC 1,356 ms
97,856 KB
testcase_20 AC 1,359 ms
97,800 KB
testcase_21 AC 1,347 ms
97,628 KB
testcase_22 AC 1,357 ms
97,504 KB
testcase_23 AC 1,366 ms
97,760 KB
testcase_24 AC 1,349 ms
97,748 KB
testcase_25 AC 1,349 ms
97,732 KB
testcase_26 AC 1,356 ms
97,796 KB
testcase_27 AC 1,345 ms
97,740 KB
testcase_28 AC 1,338 ms
97,708 KB
testcase_29 AC 1,341 ms
97,888 KB
testcase_30 AC 1,351 ms
97,636 KB
testcase_31 AC 1,358 ms
97,724 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import numpy as np


def convolve(f, g):
  fft_len = 1
  while 2 * fft_len < len(f) + len(g) - 1:
    fft_len *= 2
  fft_len *= 2
  Ff = np.fft.rfft(np.array(f, np.int64), fft_len)
  Fg = np.fft.rfft(np.array(g, np.int64), fft_len)
  Fh = Ff * Fg
  h = np.fft.irfft(Fh, fft_len)
  h = np.rint(h).astype(np.int64)
  return h[:len(f) + len(g) - 1]


n, m, x = map(int, input().split())
c = list(map(int, input().split()))
color = [[0] * n for _ in range(5)]
point = [[0] * n for _ in range(5)]
for i in range(n):
  color[c[i] - 1][i] += 1
for _ in range(m):
  a, b, y = map(int, input().split())
  point[b - 1][n - a] += y

score_f = [convolve(color[i], point[i])[n - 1:] for i in range(5)]
score = [
  score_f[0][i] + score_f[1][i] + score_f[2][i] + score_f[3][i] + score_f[4][i]
  for i in range(n)]

ans = x * n
for i in range(n):
  ans = max(ans, i * x + score[i])
print(ans)
0