UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#203822#3569. 最优子序列drdilyor100543ms5508kbC++367b2024-03-24 09:03:452024-03-24 12:01:19

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
int n,m;
int a[200005];
int dp[200005];
int g[200005];
signed main(){
	cin>>n>>m;
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=1;i<=n;i++){
		dp[i]=a[i];
		dp[i]=max(dp[i],g[(m-a[i]%m)%m]+a[i]);
		g[a[i]%m]=max(g[a[i]%m],dp[i]);
	}
	cout<<*max_element(dp+1,dp+n+1)<<"\n";
	return 0;
}

详细

小提示:点击横条可展开更详细的信息

Test #1:

score: 10
Accepted
time: 0ms
memory: 1204kb

input:

20 13
749987623 375211210 944589514 64972338 389342463 507674971 991531334 890802757 32576979 781213...

output:

2166559486

result:

ok single line: '2166559486'

Test #2:

score: 10
Accepted
time: 0ms
memory: 1204kb

input:

20 15
99582796 12294885 852348789 926605817 849204941 270471458 892887566 974067892 841800457 157511...

output:

2612569905

result:

ok single line: '2612569905'

Test #3:

score: 10
Accepted
time: 0ms
memory: 1280kb

input:

20 114514
292793712 565481935 809761776 941466148 554645876 177476807 703263128 623014274 810635044 ...

output:

941466148

result:

ok single line: '941466148'

Test #4:

score: 10
Accepted
time: 4ms
memory: 1288kb

input:

5000 100
947291260 964017567 669765758 43013623 53333014 819988146 911217742 494187329 319940221 106...

output:

46295823400

result:

ok single line: '46295823400'

Test #5:

score: 10
Accepted
time: 4ms
memory: 1284kb

input:

5000 2
964428160 970707036 188825719 674826526 726016066 685695742 349231170 584008877 274267609 734...

output:

1268402153500

result:

ok single line: '1268402153500'

Test #6:

score: 10
Accepted
time: 2ms
memory: 1320kb

input:

5000 5000
972867911 291165229 665116301 137971950 441605559 496300169 443483413 438670482 148278584 ...

output:

4230095000

result:

ok single line: '4230095000'

Test #7:

score: 10
Accepted
time: 135ms
memory: 5508kb

input:

200000 151515
452179336 951343439 696121316 19484808 308437468 425400338 992090515 244609102 3305997...

output:

6555540551

result:

ok single line: '6555540551'

Test #8:

score: 10
Accepted
time: 141ms
memory: 4724kb

input:

200000 51113
667097295 591541403 926240086 85226095 181629757 152240070 721023193 735997444 65337067...

output:

9435153122

result:

ok single line: '9435153122'

Test #9:

score: 10
Accepted
time: 133ms
memory: 4328kb

input:

200000 177
166454880 278617410 567880671 333893483 19488273 411375222 356160463 802630092 539902174 ...

output:

737190980432

result:

ok single line: '737190980432'

Test #10:

score: 10
Accepted
time: 124ms
memory: 4328kb

input:

200000 14
585315962 94718848 884602638 130460488 727305959 336131767 678306907 786520584 588410644 6...

output:

8849689714432

result:

ok single line: '8849689714432'

Extra Test:

score: 0
Extra Test Passed