QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#859768 | #9679. 盒子 | lgvc | 73 | 2581ms | 525072kb | C++23 | 3.4kb | 2025-01-17 23:10:32 | 2025-01-17 23:10:34 |
Judging History
answer
#include <bits/stdc++.h>
#define int __int128
static char buf[1000000],*paa=buf,*pd=buf;
static char buf2[1000000],*pp=buf2;
#define getchar() paa==pd&&(pd=(paa=buf)+fread(buf,1,1000000,stdin),paa==pd)?EOF:*paa++
inline void pc(char ch){
if(pp-buf2==1000000) fwrite(buf2,1,1000000,stdout),pp=buf2;
*pp++=ch;
}
inline void pcc(){
fwrite(buf2,1,pp-buf2,stdout);
pp=buf2;
}
inline int read(void){
int w=1;
register int x(0);register char c(getchar());
while(c<'0'||c>'9'){if(c=='-') w=-1;c=getchar();}
while(c>='0'&&c<='9')x=(x<<1)+(x<<3)+(c^48),c=getchar();
return w*x;
}
void write(int x){
static int sta[20];
int top=0;
do{
sta[top++]=x%10,x/=10;
}while(x);
while(top) pc(sta[--top]+48);
}
void we(int x){
write(x);
pc('\n');
}
int T,N,M,K,C,a[1000009],rr[1000009],ff[1000009],su[1000009];
int dp[1000009],laz[30000009],ls[30000009],rs[30000009],kk,rt;
inline int fx(int x) {
return (x%K)*(K-C);
}
#define md ((l+r)>>1)
int nw() {
++kk;
laz[kk]=ls[kk]=rs[kk]=0;
return kk;
}
void up(int& n,int l,int r,int L,int R,int v) {
if(r<L||R<l) return;
if(!n) {
n=nw();
}
if(L<=l&&r<=R) {
laz[n]=v;
return;
}
if(laz[n]) {
if(!ls[n]) ls[n]=nw();
if(!rs[n]) rs[n]=nw();
laz[ls[n]]=laz[n];
laz[rs[n]]=laz[n];
laz[n]=0;
}
up(ls[n],l,md,L,R,v);
up(rs[n],md+1,r,L,R,v);
}
int qr(int n,int l,int r,int p) {
if(laz[n]) return laz[n];
if(p<=md) return qr(ls[n],l,md,p);
return qr(rs[n],md+1,r,p);
}
signed main(void) {
T=read();
int inf=1;
for(int i=1;i<=36;i++) inf*=10;
while(T--) {
N=read();M=read();K=read();C=read();
int ans=0;
for(int i=1;i<=N;i++) {
a[i]=read();
ans+=a[i];
su[i]=a[i]+su[i-1];
ff[i]=su[i]-su[std::max(i-M+1,(__int128)0)];
}
if(C==1) {
int p=1;
while(1) {
while(p<=N&&(a[p]==0)) p++;
if(p>N) break;
ans-=(a[p]/K)*(K-C);
a[p]%=K;
while(p<=N&&(a[p]==0)) p++;
if(p>N) break;
int su=0;
for(int i=p;i<p+M&&i<=N;i++) {
su+=a[i];
}
int le=K;
for(int i=p;i<p+M&&i<=N;i++) {
int tq=std::min(a[i],le);
le-=tq;a[i]-=tq;
}
ans-=(K-le)-C;
}
printf("%lld\n",(long long)(ans));
continue;
}
rt=0;kk=0;
up(rt,0,K-1,0,K-1,N);
for(int i=N;i>=1;i--) {
int ww=su[i]%K;
if(ww>ff[i]) {
if(ww<=K-2) up(rt,0,K-1,ww+1,K-1,i);
up(rt,0,K-1,0,ww-ff[i]-1,i);
} else if(ff[i]<=K-2) up(rt,0,K-1,ww+1,ww-ff[i]-1+K,i);
rr[i]=qr(rt,0,K-1,su[i-1]%K);
}
dp[N+1]=0;
for(int i=N;i>=1;i--) {
dp[i]=inf;
for(int j=rr[i];j>=i&&dp[i]>dp[j+1];j--) {
dp[i]=std::min(dp[i],dp[j+1]+(su[j]-su[i-1])%K*(K-C));
}
int ss=su[rr[i]]-su[i-1];
ss%=K;
dp[i]=std::min(dp[i],dp[rr[i]+1]+C*(K-ss));
}
printf("%lld\n",(long long)((dp[1]+ans*C)/K));
}
}
详细
Subtask #1:
score: 17
Accepted
Test #1:
score: 17
Accepted
time: 1ms
memory: 18264kb
input:
3 5 2 4 3 2 2 1 2 2 4 2 4 3 2 4 1 1 10 3 5 1 2 2 2 2 1 1 1 10 2 2
output:
7 7 6
result:
ok 3 number(s): "7 7 6"
Test #2:
score: 17
Accepted
time: 0ms
memory: 18068kb
input:
65 7 1 27 22 70 29 32 15 69 79 84 10 2 2 1 76 63 99 67 75 30 29 45 79 23 9 1 4 3 47 91 10 30 91 29 12 14 53 10 1 5 4 92 22 92 27 30 50 59 6 57 58 5 2 15 15 59 27 70 24 11 5 2 42 42 70 50 42 55 5 6 2 54 46 67 14 52 80 95 3 10 2 89 88 55 14 45 14 90 81 38 40 54 17 5 2 93 86 35 58 76 64 73 6 1 45 43 63...
output:
320 293 287 398 191 222 271 445 285 344 307 270 348 312 370 427 199 184 318 502 344 197 330 233 262 220 454 243 160 280 482 580 330 373 202 293 228 590 268 475 253 494 523 476 186 223 368 323 368 392 507 494 132 209 224 250 297 216 525 557 172 448 433 430 578
result:
ok 65 numbers
Test #3:
score: 17
Accepted
time: 0ms
memory: 18136kb
input:
6 72 4 97 91 33 34 16 21 70 62 12 30 49 27 64 63 82 53 69 14 50 52 59 19 72 79 26 86 55 50 41 85 18 8 97 51 30 7 29 43 12 10 19 13 50 60 57 23 23 11 77 23 58 35 17 47 37 21 47 65 66 49 80 51 67 39 62 80 100 59 12 17 15 71 86 97 59 4 101 92 89 100 35 32 57 26 43 81 44 36 78 47 54 28 96 80 55 82 9 95 ...
output:
3114 3115 2543 4767 3371 5050
result:
ok 6 numbers
Test #4:
score: 17
Accepted
time: 0ms
memory: 18136kb
input:
5 100 2 52 49 90 44 90 2 13 5 21 25 6 10 45 70 3 15 46 46 65 22 28 36 68 50 60 92 3 77 56 98 26 41 42 56 29 31 70 59 45 28 16 46 55 76 79 82 31 26 23 90 39 72 94 3 98 15 68 33 91 81 85 40 38 43 10 42 66 79 56 72 37 3 23 32 41 57 47 75 27 61 30 21 46 66 87 67 59 88 29 82 28 38 46 8 21 77 21 7 52 85 9...
output:
4458 5051 4722 4797 4419
result:
ok 5 number(s): "4458 5051 4722 4797 4419"
Subtask #2:
score: 21
Accepted
Dependency #1:
100%
Accepted
Test #5:
score: 21
Accepted
time: 1ms
memory: 18092kb
input:
65 7 1 266582645 266569542 368884862 154420474 168221985 75773522 366018465 417636088 444993440 10 2 375072157 375064876 370894262 247786067 280616106 111957276 105186734 167332630 296036702 83312734 27516860 167992391 9 2 454297753 454278488 133388246 410399039 130735692 54284254 59071687 238415181...
output:
1995896424 1858609919 1381456401 321041313 291091545 477588347 289709453 361469964 2289570259 1271783177 2804998319 2334689494 6346683 1306086776 1217591019 2931026151 82894799 4113412168 736303075 1741957950 1626950812 1474570427 271372945 890904128 1836210163 2311104502 442130776 1000647155 577626...
result:
ok 65 numbers
Test #6:
score: 21
Accepted
time: 1ms
memory: 18180kb
input:
6 72 4 242374549 242365525 38844937 40032377 18714548 24800811 84693265 75047761 14536480 36314334 58797147 32336071 76679761 75273517 99158666 64125288 82774059 16309377 60419269 62239133 71112327 22351765 87225054 95172626 31326678 103490938 66193376 59895216 49360526 102592480 21448285 9652018 11...
output:
3974462287 4224984385 1733288885 8325997896 5059153478 40261092159
result:
ok 6 numbers
Test #7:
score: 21
Accepted
time: 1ms
memory: 20624kb
input:
1 500 2 354073912 354070901 103001781 42959285 180870728 201578289 316169223 154752231 317354002 6638182 44466485 14386285 73379297 87770781 18223196 33124145 156079264 246018931 10578388 51471777 161752727 160456489 229844974 76330197 98605083 125308554 239444220 174429528 209209107 323376219 84913...
output:
86216679257
result:
ok 1 number(s): "86216679257"
Test #8:
score: 21
Accepted
time: 1ms
memory: 18524kb
input:
1 500 20 273616127 273602441 26614212 23411169 19558518 16664196 19090986 16350102 5912558 3870688 26712443 6142845 170470 19109904 6922006 24712421 11896598 17318891 21325174 141163 5408983 15660597 23612887 9891123 26907428 16530024 4482988 10719355 16344020 22216200 245875 16759681 10577214 72911...
output:
6803106876
result:
ok 1 number(s): "6803106876"
Test #9:
score: 21
Accepted
time: 1ms
memory: 20380kb
input:
1 500 2 435366152 435362633 89998523 158358733 399932095 426417200 212637701 39105038 172725690 333450358 154179717 225701646 211865713 129216890 431369897 81727468 351898488 35152016 282752414 321491910 356770718 192131099 105593884 68922757 332781959 383094801 119327970 88882068 180343909 51850089...
output:
111591964444
result:
ok 1 number(s): "111591964444"
Test #10:
score: 21
Accepted
time: 0ms
memory: 20344kb
input:
1 500 21 165989903 165979717 12982452 1015773 659164 5850898 1701898 15571890 9406918 1572505 8375651 9619093 6620744 8384806 5302316 7632891 9841137 13045373 6926386 11935670 11633238 6164954 8189411 3791112 9150923 2460051 10202136 11450596 15654022 14452115 12960780 7477864 6532113 10726171 13852...
output:
3944090329
result:
ok 1 number(s): "3944090329"
Test #11:
score: 21
Accepted
time: 0ms
memory: 20484kb
input:
1 500 6 389959398 389945949 56987266 127155738 94040682 59219873 127125401 40037492 69997176 34299639 65138879 11275473 9365673 54512712 34893436 2068132 64977960 68602281 88290707 112932431 104475198 43004625 49517192 51077183 8570833 87653830 37455029 87392146 118234849 90214713 27737209 44971800 ...
output:
32262964163
result:
ok 1 number(s): "32262964163"
Test #12:
score: 21
Accepted
time: 0ms
memory: 18272kb
input:
65 7 3 266582645 159623142 122961621 51473491 56073995 25257841 122006155 139212030 148331147 10 3 375072157 304564214 247262841 165190711 187077404 74638184 70124489 111555087 197357801 55541823 25811469 18344573 9 3 234619263 223896636 15042577 45925023 141298696 45011760 18689845 20338139 8208536...
output:
478869426 995230079 479310867 187887430 125972845 242252711 922889080 770172554 496451427 187770448 244024738 414072322 427736392 654939944 277093702 965068223 689495866 58152208 294626530 672521632 185394417 710653017 98812501 394528643 209018085 36586351 822530664 70520600 462471184 446136289 1687...
result:
ok 65 numbers
Test #13:
score: 21
Accepted
time: 0ms
memory: 18104kb
input:
6 72 3 242374549 172130502 51793250 53376502 24952731 33067748 112924353 19381973 48419112 78396196 43114761 102239681 100364689 132211555 85500384 110365412 21745836 80559026 82985510 94816436 29802353 116300071 126896835 41768904 137987917 88257835 79860288 65814035 136789973 28597713 12869357 156...
output:
4132099777 1733710257 3779052858 8407036917 924818769 3223052605
result:
ok 6 numbers
Test #14:
score: 21
Accepted
time: 0ms
memory: 18440kb
input:
1 500 2 354073912 325738978 103001781 42959285 180870728 201578289 316169223 154752231 317354002 6638182 44466485 14386285 73379297 87770781 18223196 33124145 156079264 246018931 10578388 51471777 161752727 160456489 229844974 76330197 98605083 125308554 239444220 174429528 209209107 323376219 84913...
output:
81106428579
result:
ok 1 number(s): "81106428579"
Test #15:
score: 21
Accepted
time: 1ms
memory: 18544kb
input:
1 500 5 273616127 160434176 106456850 93644675 66656785 76363943 65400406 23650229 15482752 106849774 24571377 681880 76439616 27688022 98849684 47586390 69275565 85300695 564651 21635930 62642387 94451546 39564492 107629713 66120096 17931952 42877420 65376080 88864799 983497 67038725 42308855 29164...
output:
17257776079
result:
ok 1 number(s): "17257776079"
Test #16:
score: 21
Accepted
time: 0ms
memory: 18368kb
input:
1 500 2 435366152 398649078 89998523 158358733 399932095 426417200 212637701 39105038 172725690 333450358 154179717 225701646 211865713 129216890 431369897 81727468 351898488 35152016 282752414 321491910 356770718 192131099 105593884 68922757 332781959 383094801 119327970 88882068 180343909 51850089...
output:
104848974697
result:
ok 1 number(s): "104848974697"
Test #17:
score: 21
Accepted
time: 0ms
memory: 18540kb
input:
1 500 5 165989903 100374622 54526297 4266247 2768488 24573770 7147969 65401935 39509054 6604519 35177733 40400191 27807122 35216184 22269727 32058142 41332776 54790564 29090821 50129812 48859600 25892804 34395526 15922668 38433874 10332215 42848972 48092502 65746893 60698882 54435273 31407026 274348...
output:
10791686119
result:
ok 1 number(s): "10791686119"
Test #18:
score: 21
Accepted
time: 2ms
memory: 18416kb
input:
1 500 2 389959398 257172808 170961798 381467212 282122046 177659617 381376203 120112474 209991526 102898915 195416635 33826418 28097017 163538135 104680306 6204395 194933879 205806841 264872119 338797293 313425593 129013875 148551575 153231547 25712498 262961488 112365085 262176438 354704545 2706441...
output:
70633680163
result:
ok 1 number(s): "70633680163"
Subtask #3:
score: 24
Accepted
Dependency #2:
100%
Accepted
Test #19:
score: 24
Accepted
time: 5ms
memory: 18136kb
input:
675 7 1 422354805 422341490 454825944 855928 732032335 527631370 802310248 169171182 698073930 10 2 427057723 427043700 42169133 20207616 278144546 308918504 300442364 324244431 260608054 173515390 341481874 300791714 9 1 292679607 292675677 567543518 428324078 177878038 152016847 183659604 15047788...
output:
3384834362 2350467534 2556127443 2044784084 2876771096 1607215070 1575868300 1620729952 434758877 650731478 212363736 349228291 411259201 531177182 1327894667 1218504782 20026823 1505720391 477596410 575644881 1422775487 1598873461 4290650600 1538908729 440414186 448209748 827494742 725317438 234932...
result:
ok 675 numbers
Test #20:
score: 24
Accepted
time: 5ms
memory: 18220kb
input:
69 72 6 193446326 193440944 51175416 63892226 37399893 7704632 10465357 9579771 45185989 54956878 62196288 32855303 32241594 14010023 57358129 64047905 22027969 20331047 36570649 16683661 27569066 52177329 28162385 22805734 50074174 30167471 34536887 17679270 61499309 51469644 35091690 52497362 5293...
output:
2636849165 9162527389 11486238001 6987733756 9313638287 44092702230 6824094078 27494174580 24590902348 12290990480 9060592920 22797870489 1693063587 5915956244 4933735492 638437124 4846040103 229804267 4639842524 440556375 1945340014 6884658020 13942682785 2500182663 1334849658 4313186861 4995918394...
result:
ok 69 numbers
Test #21:
score: 24
Accepted
time: 4ms
memory: 18676kb
input:
7 775 16 446473479 446461584 50021387 1046312 2267569 11566056 13834444 2872343 5221033 24601238 38777542 1667368 8112990 25495490 25291177 36228200 12031178 15542149 19751154 37741235 27493609 32975572 50970609 1338410 42740146 31189191 54338516 14468668 22455420 23166460 30849752 15823304 17097737...
output:
21591512788 2393929904 19067125974 16069250321 9347807700 2510173416 4235227063
result:
ok 7 numbers
Test #22:
score: 24
Accepted
time: 4ms
memory: 25360kb
input:
1 5000 64 273616127 273602441 8316941 7315990 6112037 5207561 5965933 5109407 1847674 1209590 8347638 1919639 53272 5971845 2163127 7722631 3717687 5412153 6664117 44114 1690307 4893936 7379027 3090976 8408571 5165632 1400934 3349799 5107506 6942562 76836 5237400 3305379 2278485 377591 5505791 81798...
output:
21461992436
result:
ok 1 number(s): "21461992436"
Test #23:
score: 24
Accepted
time: 6ms
memory: 27696kb
input:
1 5000 4 435366152 435362633 44999262 79179367 199966048 213208600 106318851 19552519 133166286 86362845 166725179 77089859 112850823 105932857 64608445 215684949 40863734 175949244 17576008 141376207 160745955 178385359 96065550 52796942 34461379 166390980 191547401 59663985 44441034 90171955 25925...
output:
549587199180
result:
ok 1 number(s): "549587199180"
Test #24:
score: 24
Accepted
time: 5ms
memory: 25072kb
input:
1 5000 67 165989903 165979717 4069127 318377 206604 1833864 533431 4880741 2948437 492875 2625204 3014940 2075159 2628074 1661920 2392399 3084536 4088848 2170957 3741031 3646239 1932299 2566831 1188259 2868200 771061 3197685 3588993 4906485 4529767 4062334 2343808 2047379 3361934 4341838 3972465 408...
output:
12556772938
result:
ok 1 number(s): "12556772938"
Test #25:
score: 24
Accepted
time: 1ms
memory: 24692kb
input:
1 5000 16 389959398 389945949 21370225 47683401 35265256 22207452 47672025 15014059 26248941 12862365 24427079 4228303 3512128 20442267 13085038 775550 24366735 25725855 33109015 42349661 39178199 16126735 18568947 19153944 3214063 32870186 14045636 32772055 44338068 33830517 10401453 16864425 22038...
output:
121553452006
result:
ok 1 number(s): "121553452006"
Test #26:
score: 24
Accepted
time: 6ms
memory: 27868kb
input:
1 5000 1 484270333 484253595 841850258 365640544 514155321 790775957 225406849 409063934 11040205 592779172 416926556 741963100 389693656 389280818 506231671 844653262 463341905 897293260 537885330 526291454 679458315 689963743 600187312 20611828 341712764 279980921 466956774 943218403 847294769 323...
output:
2398663533053
result:
ok 1 number(s): "2398663533053"
Test #27:
score: 24
Accepted
time: 4ms
memory: 16108kb
input:
675 7 2 422354805 285537466 227412972 427964 366016168 263815685 401155124 84585591 349036965 10 4 427057723 282168105 21084567 10103808 139072273 154459252 150221182 162122215 130304027 86757695 170740937 150395857 9 2 292679607 259056388 283771759 214162039 88939019 76008424 91829802 75238942 6628...
output:
1281998452 846504315 1177201926 1244366214 859653970 1068345137 11340970 1320562183 400865472 481715073 478664629 85198453 170450240 504528911 362058350 1311269726 161399743 666545905 456952766 31597827 576075364 201991249 801284397 1832819130 1040004407 77797143 1585415338 348660203 705359096 38980...
result:
ok 675 numbers
Test #28:
score: 24
Accepted
time: 4ms
memory: 18044kb
input:
69 72 4 193446326 156017334 76763125 95838340 56099840 11556948 15698035 14369656 67778984 82435318 93294432 49282955 48362391 21015034 86037194 96071858 33041954 30496570 54855974 25025491 41353598 78265993 42243577 34208601 75111261 45251206 51805331 26518905 92248965 77204467 52637535 78746043 79...
output:
3215881475 3006610471 5246570429 3238360783 938987406 4073747287 3122008792 6648270607 636574977 3475880972 1651214104 5565563436 2250727090 3449327651 12804686865 2144349108 1734126445 12550872114 81507507 2093648640 8340052808 5859865404 7720643599 3302434708 3627602566 3157231084 2336511356 14095...
result:
ok 69 numbers
Test #29:
score: 24
Accepted
time: 6ms
memory: 18508kb
input:
7 775 4 446473479 320805022 200085547 4185245 28035257 9070274 46264225 55337777 11489372 20884131 98404951 155110168 6669469 32451958 101981959 101164707 144912802 48124710 62168594 79004615 150964940 109974437 131902288 203882439 5353638 170960583 124756764 217354065 57874671 89821678 92665838 123...
output:
65577051543 4801906201 3255255262 23210316783 27778923619 47527989894 53449595162
result:
ok 7 numbers
Test #30:
score: 24
Accepted
time: 6ms
memory: 27748kb
input:
1 5000 5 273616127 160434176 106456850 93644675 66656785 76363943 65400406 23650229 15482752 106849774 24571377 681880 76439616 27688022 98849684 47586390 69275565 85300695 564651 21635930 62642387 94451546 39564492 107629713 66120096 17931952 42877420 65376080 88864799 983497 67038725 42308855 2916...
output:
172574692326
result:
ok 1 number(s): "172574692326"
Test #31:
score: 24
Accepted
time: 7ms
memory: 28740kb
input:
1 5000 2 435366152 398649078 89998523 158358733 399932095 426417200 212637701 39105038 172725690 333450358 154179717 225701646 211865713 129216890 431369897 81727468 351898488 35152016 282752414 321491910 356770718 192131099 105593884 68922757 332781959 383094801 119327970 88882068 180343909 5185008...
output:
1031639792673
result:
ok 1 number(s): "1031639792673"
Test #32:
score: 24
Accepted
time: 4ms
memory: 24812kb
input:
1 5000 5 165989903 100374622 54526297 4266247 2768488 24573770 7147969 65401935 39509054 6604519 35177733 40400191 27807122 35216184 22269727 32058142 41332776 54790564 29090821 50129812 48859600 25892804 34395526 15922668 38433874 10332215 42848972 48092502 65746893 60698882 54435273 31407026 27434...
output:
108065589240
result:
ok 1 number(s): "108065589240"
Test #33:
score: 24
Accepted
time: 7ms
memory: 28872kb
input:
1 5000 2 389959398 257172808 170961798 381467212 282122046 177659617 381376203 120112474 209991526 102898915 195416635 33826418 28097017 163538135 104680306 6204395 194933879 205806841 264872119 338797293 313425593 129013875 148551575 153231547 25712498 262961488 112365085 262176438 354704545 270644...
output:
704923104176
result:
ok 1 number(s): "704923104176"
Test #34:
score: 24
Accepted
time: 3ms
memory: 27124kb
input:
1 5000 2 484270333 300111906 420925129 182820272 257077661 112703425 204531967 5520103 296389586 208463278 370981550 194846828 194640409 253115836 422326631 231670953 448646630 268942665 70957557 263145727 339729158 368479153 195004705 344981872 396261938 300093656 10305914 170856382 139990461 23347...
output:
826670866609
result:
ok 1 number(s): "826670866609"
Subtask #4:
score: 11
Accepted
Test #35:
score: 11
Accepted
time: 23ms
memory: 10160kb
input:
66664 7 2 82188055 1 35930054 4923258 36288509 46890418 53350617 49812938 68015568 10 2 460335201 1 305598063 240803174 36008172 416771728 391050572 270293987 333994588 436573185 216917970 103343453 9 3 119910901 1 35106715 29444257 72409421 49339248 23617992 3266647 38704192 75874356 72979434 10 1 ...
output:
5 8 4 13 8 3 8 13 3 4 6 10 8 5 11 13 9 14 5 7 5 11 11 4 3 9 7 4 6 5 6 4 5 12 5 9 3 5 10 12 6 6 14 15 4 7 14 14 7 5 7 6 9 5 3 10 8 8 7 6 7 5 11 6 6 5 6 7 4 9 9 9 6 4 4 5 7 6 6 13 6 10 12 5 4 10 14 7 3 7 5 4 7 9 8 13 4 4 8 10 6 6 6 15 10 15 11 3 4 6 7 5 11 13 6 16 13 8 7 10 7 14 11 7 6 9 10 10 8 4 5 7...
result:
ok 66664 numbers
Test #36:
score: 11
Accepted
time: 15ms
memory: 10916kb
input:
6690 72 3 317146495 1 142773247 81913384 80067622 35723743 45518449 71351452 126380141 180273132 191748453 112193322 28442496 150647314 26258521 303990 33345021 6621848 42880826 39589616 204452573 116325570 108705558 11387332 30299069 72815156 15654159 166930094 205234583 104153808 96042862 20541234...
output:
30 10 22 22 15 12 17 13 10 20 11 88 10 14 15 17 40 11 42 11 49 17 14 34 21 13 11 19 9 13 17 12 57 111 12 14 134 23 32 14 47 103 82 14 11 9 34 39 16 15 23 15 92 11 17 11 15 48 16 36 12 17 10 31 13 50 28 17 12 35 19 123 12 15 119 13 36 35 34 15 19 15 15 37 18 11 10 10 117 13 21 58 12 29 56 11 51 40 16...
result:
ok 6690 numbers
Test #37:
score: 11
Accepted
time: 12ms
memory: 8876kb
input:
666 775 2 246425661 1 74622578 157374905 182555425 141672098 9699671 18414135 183998918 97649169 141305719 95187406 180311055 83450992 135739288 129842641 231493124 131315020 85362268 132726174 141564017 176940415 12513491 100929354 136380053 148052188 103349185 8787084 242276294 101926333 233021909...
output:
485 39 54 99 89 32 48 111 35 52 42 202 47 771 55 38 59 26 89 50 31 32 298 36 63 56 251 49 60 80 33 35 34 139 52 48 183 30 451 83 30 35 91 1212 48 33 38 41 40 39 34 42 948 53 41 48 75 106 40 31 60 27 75 105 41 259 370 57 85 209 67 447 83 1350 53 72 74 51 33 30 77 95 49 74 49 40 27 47 459 191 102 187 ...
result:
ok 666 numbers
Test #38:
score: 11
Accepted
time: 10ms
memory: 13076kb
input:
65 9836 26 54096694 1 148800 658413 951947 2268744 878783 2182195 752030 2653278 1315450 1670737 1003031 2704024 1562015 1651614 2632695 2596293 928102 3193391 577384 744762 2401049 1562878 1463415 2091183 1946443 2857417 1492929 1055634 346091 2308435 1052429 2600515 197268 3726435 3867526 1509937 ...
output:
398 302 104 198 369 549 174 168 173 300 109 275 1848 665 182 567 88 224 450 893 1083 82 2407 98 3719 111 708 793 180 111 118 137 178 615 133 96 118 155 212 1247 159 341 190 566 274 127 197 95 815 128 272 84 324 392 281 118 12924 192 184 315 113 226 130 107 145
result:
ok 65 numbers
Test #39:
score: 11
Accepted
time: 10ms
memory: 16520kb
input:
7 61099 242 244205595 1 181280 1234639 800705 1545777 714732 1046286 982147 599012 1999703 378865 1631297 162955 1310757 1490341 1653883 890663 489502 319506 1542679 1775914 223824 553169 412031 836021 240362 597557 1771809 1269038 1056897 1170245 993243 1210794 1477083 536484 29428 574562 188428 51...
output:
257 432 950 624 338 2864 510
result:
ok 7 numbers
Test #40:
score: 11
Accepted
time: 9ms
memory: 35608kb
input:
1 500000 670 165989903 1 103760 406913 31838 20661 183387 53344 488074 294844 49288 262521 301494 207516 262808 166192 239240 308454 408885 217096 374103 364624 193230 256683 118826 286820 77107 319769 358900 490649 452977 406234 234381 204738 336194 434184 397247 408167 227027 26992 333880 356080 7...
output:
753
result:
ok 1 number(s): "753"
Test #41:
score: 11
Accepted
time: 12ms
memory: 35112kb
input:
1 500000 161 389959398 1 1545171 2123749 4738724 3504622 2206952 4737593 1492081 2608591 1278248 2427536 420204 349032 2031530 1300377 77074 2421539 2556607 3290337 4208662 3893486 1602657 1845362 1903498 319410 3266603 1395840 3256851 4406268 3362039 1033685 1675968 2190187 4502836 4510964 1272013 ...
output:
3166
result:
ok 1 number(s): "3166"
Test #42:
score: 11
Accepted
time: 15ms
memory: 35608kb
input:
1 500000 8 484270333 1 28988371 105231282 45705068 64269415 98846995 51132992 1380026 74097397 52115820 92745388 48711707 48660103 63278959 105581658 57917738 112161658 67235667 17739390 65786432 84932290 92119788 48751177 86245468 99065485 75023414 2576479 51585902 42714096 34997616 58369597 117902...
output:
68866
result:
ok 1 number(s): "68866"
Test #43:
score: 11
Accepted
time: 10ms
memory: 34772kb
input:
1 500000 258 250937298 1 970934 964404 14674 260332 615136 276442 25915 425152 1706415 814104 267525 482619 269638 163518 770097 672082 962227 324422 614133 1709018 727429 1849863 1429094 75376 1882816 1359939 1364688 1114162 263436 1746849 264568 1297286 1849558 1065682 1075832 1366397 1834968 7517...
output:
1968
result:
ok 1 number(s): "1968"
Test #44:
score: 11
Accepted
time: 8ms
memory: 36940kb
input:
1 500000 212 10375974 1 48414 62026 43365 73298 81433 48797 57100 22005 2464 19388 69422 74446 25996 16554 25804 8648 14720 67088 66937 93324 79934 387 32897 50137 87199 79545 19394 59958 2997 70650 85907 28571 71206 89838 52945 69947 12868 53108 40493 13917 76227 36545 57156 65989 17878 43250 80862...
output:
2397
result:
ok 1 number(s): "2397"
Subtask #5:
score: 0
Time Limit Exceeded
Dependency #1:
100%
Accepted
Dependency #2:
100%
Accepted
Dependency #3:
100%
Accepted
Dependency #4:
100%
Accepted
Test #45:
score: 27
Accepted
time: 415ms
memory: 19240kb
input:
66664 7 2 82188055 82182952 4923258 36288509 46890418 53350617 49812938 68015568 37623096 10 3 331929931 331921242 17309401 200345329 187980974 129932369 160553730 209864039 104274112 13830191 49677981 167850712 9 1 219580003 219570642 271049055 129747303 17945581 212624534 416821770 58097543 235222...
output:
296889095 1241592771 1657515872 626941645 451684006 879466175 118260103 1091911109 136693916 102442113 435169397 489652641 1693290007 63952667 931786480 1087776227 2641991160 1728729446 124107679 1025514315 236723996 348464995 2444556448 3173628464 1365712174 1443187896 75693829 649709941 498542929 ...
result:
ok 66664 numbers
Test #46:
score: 27
Accepted
time: 396ms
memory: 19124kb
input:
6690 72 3 317146495 317140712 81913384 80067622 35723743 45518449 71351452 126380141 180273132 191748453 112193322 28442496 150647314 26258521 303990 33345021 6621848 42880826 39589616 204452573 116325570 108705558 11387332 30299069 72815156 15654159 166930094 205234583 104153808 96042862 205412349 ...
output:
7974009272 1214620325 1449365148 4360508846 9590619633 3850939011 4548969784 27477185648 6753864264 1536034420 1522621920 4094660201 1906768847 1772304002 2279661793 892444444 4769747948 4177800235 955171016 2181241032 3665417993 3891254505 510584441 5597439319 2011680426 10587118617 5011456891 3574...
result:
ok 6690 numbers
Test #47:
score: 27
Accepted
time: 382ms
memory: 23508kb
input:
666 775 2 246425661 246414716 157374905 182555425 141672098 9699671 18414135 183998918 97649169 141305719 95187406 180311055 83450992 135739288 129842641 231493124 131315020 85362268 132726174 141564017 176940415 12513491 100929354 136380053 148052188 103349185 8787084 242276294 101926333 233021909 ...
output:
95522847717 38439021116 6311570500 17228364867 13543766977 73309826801 7365270698 13681784790 13703497315 1364960681 6261794913 5453184626 994017590 6748841285 23425616586 24202530826 2248445845 12209329764 32312872364 12590782544 33000957368 9810428106 74228275098 36673953186 16792709681 3045696079...
result:
ok 666 numbers
Test #48:
score: 27
Accepted
time: 502ms
memory: 39824kb
input:
65 9836 26 54096694 54089601 658413 951947 2268744 878783 2182195 752030 2653278 1315450 1670737 1003031 2704024 1562015 1651614 2632695 2596293 928102 3193391 577384 744762 2401049 1562878 1463415 2091183 1946443 2857417 1492929 1055634 346091 2308435 1052429 2600515 197268 3726435 3867526 1509937 ...
output:
20474959177 110727187202 232511054342 193999430424 65161133012 64907542323 170677559966 682258026 92443025882 41082803103 63052585788 60262103056 34449819791 48238755874 26782553417 151039307024 14350064106 37346125237 59738724008 239284958 34048029116 35329851852 32823669370 18193123539 12445046945...
result:
ok 65 numbers
Test #49:
score: 27
Accepted
time: 852ms
memory: 118308kb
input:
7 61099 242 244205595 244191370 1234639 800705 1545777 714732 1046286 982147 599012 1999703 378865 1631297 162955 1310757 1490341 1653883 890663 489502 319506 1542679 1775914 223824 553169 412031 836021 240362 597557 1771809 1269038 1056897 1170245 993243 1210794 1477083 536484 29428 574562 188428 5...
output:
61834159885 33224677412 919972481955 37968226528 122986011888 180520591759 645733948514
result:
ok 7 numbers
Test #50:
score: 27
Accepted
time: 2581ms
memory: 372860kb
input:
1 500000 670 165989903 165979717 406913 31838 20661 183387 53344 488074 294844 49288 262521 301494 207516 262808 166192 239240 308454 408885 217096 374103 364624 193230 256683 118826 286820 77107 319769 358900 490649 452977 406234 234381 204738 336194 434184 397247 408167 227027 26992 333880 356080 ...
output:
123732653235
result:
ok 1 number(s): "123732653235"
Test #51:
score: 27
Accepted
time: 1025ms
memory: 410412kb
input:
1 500000 161 389959398 389945949 2123749 4738724 3504622 2206952 4737593 1492081 2608591 1278248 2427536 420204 349032 2031530 1300377 77074 2421539 2556607 3290337 4208662 3893486 1602657 1845362 1903498 319410 3266603 1395840 3256851 4406268 3362039 1033685 1675968 2190187 4502836 4510964 1272013 ...
output:
1211918119095
result:
ok 1 number(s): "1211918119095"
Test #52:
score: 27
Accepted
time: 662ms
memory: 481640kb
input:
1 500000 8 484270333 484253595 105231282 45705068 64269415 98846995 51132992 1380026 74097397 52115820 92745388 48711707 48660103 63278959 105581658 57917738 112161658 67235667 17739390 65786432 84932290 92119788 48751177 86245468 99065485 75023414 2576479 51585902 42714096 34997616 58369597 1179023...
output:
30214279625856
result:
ok 1 number(s): "30214279625856"
Test #53:
score: 27
Accepted
time: 1285ms
memory: 391796kb
input:
1 500000 258 250937298 250929363 964404 14674 260332 615136 276442 25915 425152 1706415 814104 267525 482619 269638 163518 770097 672082 962227 324422 614133 1709018 727429 1849863 1429094 75376 1882816 1359939 1364688 1114162 263436 1746849 264568 1297286 1849558 1065682 1075832 1366397 1834968 751...
output:
486373985787
result:
ok 1 number(s): "486373985787"
Test #54:
score: 27
Accepted
time: 1064ms
memory: 227232kb
input:
1 500000 212 10375974 10374346 62026 43365 73298 81433 48797 57100 22005 2464 19388 69422 74446 25996 16554 25804 8648 14720 67088 66937 93324 79934 387 32897 50137 87199 79545 19394 59958 2997 70650 85907 28571 71206 89838 52945 69947 12868 53108 40493 13917 76227 36545 57156 65989 17878 43250 8086...
output:
24456634944
result:
ok 1 number(s): "24456634944"
Test #55:
score: 27
Accepted
time: 37ms
memory: 18828kb
input:
6652 7 3 6669523 6048724 3266910 4304961 1278485 1276651 1723410 3570418 4084794 10 5 244776192 136074052 38653890 51995100 38489327 79652776 16261771 36843143 38189355 43645997 11442792 73521228 9 4 49173189 37850669 8864114 13297907 13859617 20749515 5866008 15266791 20651603 21281220 18829668 10 ...
output:
18264031 272148104 113552007 1889030225 367448774 315511646 83644964 1154720347 24120503 790114848 448031063 28292436 174344753 354862905 146760212 115054786 393390397 619997062 282224273 1145062978 284963743 403206682 195775879 678232877 474887053 609364935 167926379 72754995 31184659 66845285 6883...
result:
ok 6652 numbers
Test #56:
score: 27
Accepted
time: 424ms
memory: 19112kb
input:
6690 72 3 317146495 265653183 81913384 80067622 35723743 45518449 71351452 126380141 180273132 191748453 112193322 28442496 150647314 26258521 303990 33345021 6621848 42880826 39589616 204452573 116325570 108705558 11387332 30299069 72815156 15654159 166930094 205234583 104153808 96042862 205412349 ...
output:
6904853928 1011786520 1016468972 6839632670 1986506288 6862591895 4883265492 8843483758 515522223 4136974975 6209909559 5892932948 1319196692 5725312193 444077660 4369631176 657304081 3688598311 2749277184 1257988570 2110677180 10651521606 4747863870 3767745489 4327550134 9463103102 606280552 200819...
result:
ok 6690 numbers
Test #57:
score: 27
Accepted
time: 422ms
memory: 21592kb
input:
666 775 2 246425661 160524119 157374905 182555425 141672098 9699671 18414135 183998918 97649169 141305719 95187406 180311055 83450992 135739288 129842641 231493124 131315020 85362268 132726174 141564017 176940415 12513491 100929354 136380053 148052188 103349185 8787084 242276294 101926333 233021909 ...
output:
68094954810 73376797535 41052379195 107447377756 6131932471 22808465873 9510678101 19996336206 108411744579 24126115792 93331181775 8508863319 14274153072 41682000771 33550136931 4593548642 30737852204 22016081973 6095959627 62458160362 33109158313 40283259926 38600918144 102091882031 90810115594 25...
result:
ok 666 numbers
Test #58:
score: 27
Accepted
time: 529ms
memory: 37908kb
input:
65 9836 3 54096694 28015546 5706243 8250203 19662441 7616114 18912352 6517592 22995071 11400562 14479718 8692928 23434872 13537461 14313986 22816687 22501200 8043548 27676048 5003988 6454598 20809086 13544939 12682924 18123585 16869165 24764279 12938717 9148821 2999449 20006431 9121049 22537795 1709...
output:
101894979995 428142618780 307916502669 219412475827 661040537225 1462953675488 417582687699 365389311836 466809385454 1360914441811 342433802756 750495971756 923133501348 2696303543 504666637508 494626389156 376464935305 460547725698 56845241698 137474855446 1620902916766 551156970536 117251565862 7...
result:
ok 65 numbers
Test #59:
score: 27
Accepted
time: 623ms
memory: 126980kb
input:
7 61099 5 244205595 133070196 59756510 38754120 74815594 34592997 50640230 47535889 28992137 96785607 18337030 78954765 7886988 63440597 72132501 80047937 43108073 23691890 15464062 74665627 85954219 10833036 26773380 19942293 40463405 11633502 28921751 85755537 61421410 51153775 56639855 48072946 5...
output:
1756385313121 6188373387858 8870329328725 4421729676527 1447374814890 982940273243 5990619460130
result:
ok 7 numbers
Test #60:
score: 27
Accepted
time: 687ms
memory: 432804kb
input:
1 500000 5 165989903 100374622 54526297 4266247 2768488 24573770 7147969 65401935 39509054 6604519 35177733 40400191 27807122 35216184 22269727 32058142 41332776 54790564 29090821 50129812 48859600 25892804 34395526 15922668 38433874 10332215 42848972 48092502 65746893 60698882 54435273 31407026 274...
output:
10740695871241
result:
ok 1 number(s): "10740695871241"
Test #61:
score: 27
Accepted
time: 806ms
memory: 511960kb
input:
1 500000 2 389959398 257172808 170961798 381467212 282122046 177659617 381376203 120112474 209991526 102898915 195416635 33826418 28097017 163538135 104680306 6204395 194933879 205806841 264872119 338797293 313425593 129013875 148551575 153231547 25712498 262961488 112365085 262176438 354704545 2706...
output:
70698224132781
result:
ok 1 number(s): "70698224132781"
Test #62:
score: 27
Accepted
time: 797ms
memory: 525072kb
input:
1 500000 2 484270333 300111906 420925129 182820272 257077661 112703425 204531967 5520103 296389586 208463278 370981550 194846828 194640409 253115836 422326631 231670953 448646630 268942665 70957557 263145727 339729158 368479153 195004705 344981872 396261938 300093656 10305914 170856382 139990461 233...
output:
83147714133076
result:
ok 1 number(s): "83147714133076"
Test #63:
score: 27
Accepted
time: 730ms
memory: 464528kb
input:
1 500000 3 250937298 188093862 82938675 1261897 22388548 52901650 23773983 2228660 36563016 146751680 70012876 23007073 41505226 23188828 14062469 66228351 57798998 82751512 27900272 52815421 146975495 62558866 159088230 122902071 6482275 161922157 116954747 117363115 150228988 22752816 111566551 15...
output:
33329076529944
result:
ok 1 number(s): "33329076529944"
Test #64:
score: 27
Accepted
time: 608ms
memory: 268812kb
input:
1 500000 3 10375974 7753913 4383146 3064475 5179714 5754594 3448331 4035021 1554990 174121 1370064 4905816 5260832 1837005 1169794 1823425 611075 1040212 4740851 4730189 6594924 5648693 27312 2324714 3542996 6162060 5621156 1370472 4237037 211786 4992610 6070740 2018999 5031902 6348534 3741445 49429...
output:
1374073046872
result:
ok 1 number(s): "1374073046872"
Test #65:
score: 0
Time Limit Exceeded
input:
1 500000 5 360162245 348017099 16479 18458236 43555511 143926670 21142373 34012135 13302751 57133362 26833559 55884322 49783171 96486895 57160265 134778342 77624578 121923697 60391216 45131717 98716078 75568978 29454393 63885996 126505899 33074019 3945592 76990286 96590834 131669846 60118975 6586716...