結果

問題 No.2617 容量3のナップザック
ユーザー 👑 p-adicp-adic
提出日時 2023-12-19 22:07:04
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 464 bytes
コンパイル時間 73 ms
コンパイル使用メモリ 12,032 KB
実行使用メモリ 153,504 KB
最終ジャッジ日時 2023-12-21 23:41:36
合計ジャッジ時間 4,110 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
16,916 KB
testcase_01 AC 29 ms
10,112 KB
testcase_02 AC 27 ms
10,112 KB
testcase_03 AC 28 ms
10,112 KB
testcase_04 AC 28 ms
10,112 KB
testcase_05 AC 28 ms
10,112 KB
testcase_06 AC 28 ms
10,112 KB
testcase_07 AC 28 ms
10,112 KB
testcase_08 AC 28 ms
10,112 KB
testcase_09 AC 28 ms
10,112 KB
testcase_10 AC 28 ms
10,112 KB
testcase_11 AC 28 ms
10,112 KB
testcase_12 TLE -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
権限があれば一括ダウンロードができます

ソースコード

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