結果

問題 No.2330 Eat Slime
ユーザー tyawanmusityawanmusi
提出日時 2023-05-24 12:04:28
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,426 ms / 4,000 ms
コード長 1,042 bytes
コンパイル時間 287 ms
コンパイル使用メモリ 10,852 KB
実行使用メモリ 97,808 KB
最終ジャッジ日時 2023-08-25 03:33:46
合計ジャッジ時間 36,253 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 131 ms
29,576 KB
testcase_01 AC 127 ms
29,640 KB
testcase_02 AC 130 ms
29,704 KB
testcase_03 AC 128 ms
29,656 KB
testcase_04 AC 128 ms
29,656 KB
testcase_05 AC 131 ms
29,632 KB
testcase_06 AC 133 ms
29,664 KB
testcase_07 AC 1,093 ms
93,828 KB
testcase_08 AC 575 ms
66,528 KB
testcase_09 AC 1,135 ms
91,292 KB
testcase_10 AC 416 ms
38,096 KB
testcase_11 AC 510 ms
33,532 KB
testcase_12 AC 1,111 ms
92,424 KB
testcase_13 AC 957 ms
93,752 KB
testcase_14 AC 776 ms
37,684 KB
testcase_15 AC 926 ms
66,068 KB
testcase_16 AC 935 ms
91,540 KB
testcase_17 AC 1,418 ms
97,660 KB
testcase_18 AC 1,404 ms
97,664 KB
testcase_19 AC 1,418 ms
97,668 KB
testcase_20 AC 1,388 ms
97,612 KB
testcase_21 AC 1,415 ms
97,664 KB
testcase_22 AC 1,395 ms
97,604 KB
testcase_23 AC 1,408 ms
97,620 KB
testcase_24 AC 1,418 ms
97,652 KB
testcase_25 AC 1,413 ms
97,808 KB
testcase_26 AC 1,415 ms
97,620 KB
testcase_27 AC 1,392 ms
97,692 KB
testcase_28 AC 1,388 ms
97,612 KB
testcase_29 AC 1,410 ms
97,664 KB
testcase_30 AC 1,426 ms
97,648 KB
testcase_31 AC 1,380 ms
97,696 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())
assert 1 <= n <= 2 * 10**5
assert 1 <= m <= 2 * 10**5
assert 0 <= x <= 100
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):
  assert 1 <= c[i] <= 5
  color[c[i] - 1][i] += 1
for _ in range(m):
  a, b, y = map(int, input().split())
  assert 1 <= a <= n
  assert 1 <= b <= 5
  assert 1 <= y <= 100
  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