ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#203829 | #3569. 最优子序列 | three_zero30 | 100 | 144ms | 3596kb | C++11 | 445b | 2024-03-24 09:25:25 | 2024-03-24 12:02:01 |
answer
#include <iostream>
using namespace std;
int n,m;
const int N=2e5+2;
int a[N];
long long g[N],ans=-1;
int f(int t){
if(t%m==0)return 0;
return m-t%m;
}
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin>>n>>m;
a[0]=0;
for(int i=1;i<=n;i++){
cin>>a[i];
g[i]=0;
}
for(int i=1;i<=n;i++){
g[a[i]%m]=max(g[a[i]%m],g[f(a[i]%m)]+a[i]);
ans=max(ans,g[a[i]%m]);
}
cout<<ans<<endl;
return 0;
}
Details
小提示:点击横条可展开更详细的信息
Test #1:
score: 10
Accepted
time: 0ms
memory: 1252kb
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: 1252kb
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: 1324kb
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: 0ms
memory: 1316kb
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: 0ms
memory: 1312kb
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: 0ms
memory: 1312kb
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: 43ms
memory: 3596kb
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: 35ms
memory: 3592kb
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: 33ms
memory: 3596kb
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: 33ms
memory: 3596kb
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