結果

問題 No.2617 容量3のナップザック
ユーザー 👑 p-adicp-adic
提出日時 2023-12-19 22:06:40
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 982 ms / 2,000 ms
コード長 464 bytes
コンパイル時間 164 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 311,528 KB
最終ジャッジ日時 2023-12-21 23:41:50
合計ジャッジ時間 13,995 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
53,460 KB
testcase_01 AC 34 ms
53,460 KB
testcase_02 AC 35 ms
53,460 KB
testcase_03 AC 37 ms
53,460 KB
testcase_04 AC 35 ms
53,460 KB
testcase_05 AC 34 ms
53,460 KB
testcase_06 AC 38 ms
53,460 KB
testcase_07 AC 33 ms
53,460 KB
testcase_08 AC 37 ms
53,460 KB
testcase_09 AC 37 ms
53,460 KB
testcase_10 AC 38 ms
53,460 KB
testcase_11 AC 38 ms
53,460 KB
testcase_12 AC 447 ms
185,004 KB
testcase_13 AC 344 ms
157,328 KB
testcase_14 AC 412 ms
190,244 KB
testcase_15 AC 276 ms
135,168 KB
testcase_16 AC 437 ms
219,764 KB
testcase_17 AC 363 ms
173,136 KB
testcase_18 AC 334 ms
156,832 KB
testcase_19 AC 107 ms
99,864 KB
testcase_20 AC 327 ms
157,200 KB
testcase_21 AC 256 ms
164,116 KB
testcase_22 AC 362 ms
157,324 KB
testcase_23 AC 429 ms
192,112 KB
testcase_24 AC 67 ms
78,912 KB
testcase_25 AC 291 ms
151,492 KB
testcase_26 AC 633 ms
246,012 KB
testcase_27 AC 221 ms
129,412 KB
testcase_28 AC 65 ms
76,064 KB
testcase_29 AC 196 ms
128,516 KB
testcase_30 AC 342 ms
157,324 KB
testcase_31 AC 377 ms
166,264 KB
testcase_32 AC 400 ms
179,432 KB
testcase_33 AC 443 ms
183,780 KB
testcase_34 AC 483 ms
204,168 KB
testcase_35 AC 427 ms
178,424 KB
testcase_36 AC 982 ms
311,528 KB
testcase_37 AC 503 ms
204,488 KB
testcase_38 AC 400 ms
165,716 KB
testcase_39 AC 494 ms
193,240 KB
testcase_40 AC 459 ms
185,056 KB
testcase_41 AC 239 ms
177,784 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

R=range
N,K,s,a,b,m=map(int,input().split())
f=[s]
for i in R(2*N):f+=[(a*f[-1]+b)%m]
v=[[-9**18]for w in R(3)]
for i in R(N):v[f[i]%3]+=[-(f[i]%3+1)*f[i+N]]
for w in R(3):
	u=v[w]
	u.sort()
	u[0],b=0,len(u)
	for i in R(1,b):u[i]=u[i-1]-u[i]
	while b<3*K+3:
		u+=[u[-1]]
		b+=1
a=v[2][K]
for k in R(K):
	b=K-k
	l,r=0,b+1
	while l<r-1:
		m=(l+r)//2
		if v[1][m]-v[1][m-1]<v[0][3*b-2*m+2]-v[0][3*b-2*m]:r=m
		else:l=m
	a=max(a,v[2][k]+v[1][l]+v[0][3*b-2*l])
print(a)
0