結果

問題 No.2330 Eat Slime
ユーザー Seed57_cashSeed57_cash
提出日時 2023-05-02 16:24:24
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 2,217 ms / 4,000 ms
コード長 955 bytes
コンパイル時間 215 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 117,208 KB
最終ジャッジ日時 2024-05-01 05:06:33
合計ジャッジ時間 54,188 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 490 ms
43,988 KB
testcase_01 AC 493 ms
44,116 KB
testcase_02 AC 490 ms
43,880 KB
testcase_03 AC 487 ms
43,876 KB
testcase_04 AC 493 ms
43,608 KB
testcase_05 AC 490 ms
43,604 KB
testcase_06 AC 490 ms
43,736 KB
testcase_07 AC 1,689 ms
107,220 KB
testcase_08 AC 832 ms
71,460 KB
testcase_09 AC 1,801 ms
108,820 KB
testcase_10 AC 934 ms
52,940 KB
testcase_11 AC 1,180 ms
53,304 KB
testcase_12 AC 1,767 ms
107,284 KB
testcase_13 AC 1,435 ms
101,844 KB
testcase_14 AC 1,603 ms
65,248 KB
testcase_15 AC 1,537 ms
82,876 KB
testcase_16 AC 1,457 ms
101,972 KB
testcase_17 AC 2,147 ms
117,208 KB
testcase_18 AC 2,217 ms
116,572 KB
testcase_19 AC 2,171 ms
116,108 KB
testcase_20 AC 2,166 ms
116,604 KB
testcase_21 AC 2,155 ms
116,056 KB
testcase_22 AC 2,141 ms
115,964 KB
testcase_23 AC 2,160 ms
116,576 KB
testcase_24 AC 2,106 ms
115,996 KB
testcase_25 AC 2,137 ms
116,448 KB
testcase_26 AC 2,167 ms
116,300 KB
testcase_27 AC 2,150 ms
115,624 KB
testcase_28 AC 2,173 ms
115,804 KB
testcase_29 AC 2,125 ms
115,724 KB
testcase_30 AC 2,144 ms
116,564 KB
testcase_31 AC 2,126 ms
115,768 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import numpy as np


# https://maspypy.com/%E6%95%B0%E5%AD%A6%E3%83%BBnumpy-%E9%AB%98%E9%80%9F%E3%83%95%E3%83%BC%E3%83%AA%E3%82%A8%E5%A4%89%E6%8F%9Bfft%E3%81%AB%E3%82%88%E3%82%8B%E7%95%B3%E3%81%BF%E8%BE%BC%E3%81%BF


n, m, x = map(int, input().split())
c_list = list(map(int, input().split()))
aby_list = [tuple(map(int, input().split())) for _ in range(m)]

colors = np.zeros((n, 5), dtype=np.int32)
for i, c in enumerate(c_list):
	colors[i, c - 1] = 1
score = np.zeros((n, 5), dtype=np.int32)
for a, b, y in aby_list:
	score[a - 1, b - 1] += y


fft_len = 1
while 2 * fft_len < 2 * n - 1:
	fft_len *= 2
fft_len *= 2

h = np.zeros((fft_len, 5), dtype=np.int32)
for c in range(5):
	Fsc = np.fft.rfft(score[:, c], fft_len)
	Fco = np.fft.rfft(colors[::-1, c], fft_len)
	h[:, c] = np.rint(np.fft.irfft(Fsc * Fco, fft_len)).astype(np.int32)

hs = h.sum(axis=1)
res = n * x

for j in range(n - 1, -1, -1):
	res = max(res, hs[j] + (n - 1 - j) * x)

print(res)

0