QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#104243 | #6397. Master of Both III | Melacau# | AC ✓ | 359ms | 36236kb | C++17 | 808b | 2023-05-09 19:26:36 | 2023-05-09 19:26:38 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using s64 = long long;
const int N = 22;
const int M = 1 << N;
const int P = 998'244'353;
int n, w[N];
s64 f[M];
void rw(s64& x, s64 y) {if (y < x) x = y;}
int main() {
ios::sync_with_stdio(false);
cin >> n; int m = (1 << n) - 1; cin >> w[0];
for (int i = n - 1; i; --i) cin >> w[i];
fill(f, f + m + 1, s64(1e18));
f[1] = 0;
for (s64 S = 0; S <= m; ++S)
for (int k = 0; k < n; ++k)
rw(f[S | ((S << k) & m) | ((S << k) >> n)], f[S] + w[k]);
for (int k = 0; k < n; ++k)
for (int S = 0; S <= m; ++S)
if (S >> k & 1) rw(f[S ^ (1 << k)], f[S]);
s64 ans = 0;
for (int S = 0; S <= m; ++S) {
ans += f[S] % P * S % P;
if (ans >= P) ans -= P;
}
cout << ans << endl;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3336kb
input:
3 2 1 2
output:
45
result:
ok 1 number(s): "45"
Test #2:
score: 0
Accepted
time: 2ms
memory: 3300kb
input:
4 1919810 999999998 999999997 114114514
output:
152175989
result:
ok 1 number(s): "152175989"
Test #3:
score: 0
Accepted
time: 2ms
memory: 3360kb
input:
3 842160586 705327547 868243944
output:
78597628
result:
ok 1 number(s): "78597628"
Test #4:
score: 0
Accepted
time: 2ms
memory: 3296kb
input:
5 198327434 147392532 760837755 771109105 676721155
output:
751568230
result:
ok 1 number(s): "751568230"
Test #5:
score: 0
Accepted
time: 0ms
memory: 3364kb
input:
10 831766351 33417723 223739726 80131988 348810263 415437931 119999060 799356097 512022962 23197703
output:
308170104
result:
ok 1 number(s): "308170104"
Test #6:
score: 0
Accepted
time: 2ms
memory: 3384kb
input:
12 892965903 35291219 261557729 131390943 457251874 944586973 724767219 190756777 658923976 587806068 793999675 378390067
output:
964920873
result:
ok 1 number(s): "964920873"
Test #7:
score: 0
Accepted
time: 3ms
memory: 3600kb
input:
14 249132751 477356204 594343028 32906794 270726189 883801423 329535378 877124753 100792287 152414432 142520554 196476850 924736849 383197276
output:
796031217
result:
ok 1 number(s): "796031217"
Test #8:
score: 0
Accepted
time: 54ms
memory: 11872kb
input:
20 627365465 726842612 947302944 649244156 293375951 318148820 237155023 981487641 688151803 844901013 430309799 733877736 520864483 720366437 28746495 143052089 306590290 18586578 662663479 375430013
output:
179404754
result:
ok 1 number(s): "179404754"
Test #9:
score: 0
Accepted
time: 140ms
memory: 21420kb
input:
21 805448889 595358753 391340394 525130530 272725205 157594893 261894302 29704333 909085958 127205196 104570238 495437480 458664573 599968678 690908307 220500006 735062204 172834136 241126905 814694254 294923292
output:
260115885
result:
ok 1 number(s): "260115885"
Test #10:
score: 0
Accepted
time: 317ms
memory: 36024kb
input:
22 983532313 168907597 985120947 845727304 401817563 702073670 841923182 372888321 835052818 409509378 73797974 256997223 101497367 919762407 912878630 297947923 723342631 32114398 409524923 253958495 441987041 591475412
output:
428320025
result:
ok 1 number(s): "428320025"
Test #11:
score: 0
Accepted
time: 134ms
memory: 19844kb
input:
21 11 15 20 22 23 41 78 144 266 522 1025 2051 4114 8206 16404 32788 65554 131084 262147 524308 1048583
output:
975218988
result:
ok 1 number(s): "975218988"
Test #12:
score: 0
Accepted
time: 314ms
memory: 36132kb
input:
22 5 7 13 23 33 35 74 144 274 518 1025 2050 4108 8210 16385 32771 65555 131076 262158 524305 1048593 2097169
output:
430862284
result:
ok 1 number(s): "430862284"
Test #13:
score: 0
Accepted
time: 62ms
memory: 12936kb
input:
20 7 8 14 20 22 51 71 148 257 513 1042 2058 4116 8212 16397 32779 65556 131088 262148 524302
output:
305207398
result:
ok 1 number(s): "305207398"
Test #14:
score: 0
Accepted
time: 131ms
memory: 21416kb
input:
21 1048588 524308 262158 131078 65556 32772 16387 8203 4115 2051 1029 519 262 149 76 43 21 16 15 12 10
output:
120441696
result:
ok 1 number(s): "120441696"
Test #15:
score: 0
Accepted
time: 330ms
memory: 36228kb
input:
22 2097156 1048596 524291 262146 131080 65550 32785 16398 8209 4110 2062 1033 525 274 143 68 35 26 20 18 12 6
output:
733598329
result:
ok 1 number(s): "733598329"
Test #16:
score: 0
Accepted
time: 65ms
memory: 12912kb
input:
20 524296 262146 131082 65541 32773 16396 8202 4099 2065 1028 526 265 145 74 39 33 19 15 10 3
output:
441419655
result:
ok 1 number(s): "441419655"
Test #17:
score: 0
Accepted
time: 151ms
memory: 21508kb
input:
21 8193 27 1041 23 4097 32782 140 16403 262147 65 131074 516 524302 9 2060 65556 273 1048596 6 19 49
output:
704360700
result:
ok 1 number(s): "704360700"
Test #18:
score: 0
Accepted
time: 359ms
memory: 36128kb
input:
22 2097156 524300 139 12 262159 10 52 16 257 131076 16397 1035 65542 2062 4099 515 1048578 16 35 74 32786 8196
output:
130643050
result:
ok 1 number(s): "130643050"
Test #19:
score: 0
Accepted
time: 57ms
memory: 12004kb
input:
20 143 19 21 16403 262145 8210 1034 71 9 266 524303 32780 26 34 516 131092 2055 11 65553 4110
output:
877055041
result:
ok 1 number(s): "877055041"
Test #20:
score: 0
Accepted
time: 166ms
memory: 21036kb
input:
21 12 13 124013445 165165233 302521359 335939286 338126181 401926382 473978786 482365940 504814524 527374498 713266663 723409251 770861632 772613010 790560972 821461929 923487261 947732496 984576455
output:
302494363
result:
ok 1 number(s): "302494363"
Test #21:
score: 0
Accepted
time: 152ms
memory: 21260kb
input:
21 8 216683733 225654691 345690335 386019313 418392558 492201820 555866312 581843628 635678233 670026131 711790397 752745658 755273648 768833218 776829634 813365711 959068723 959282924 975993831 984177503
output:
68559536
result:
ok 1 number(s): "68559536"
Test #22:
score: 0
Accepted
time: 181ms
memory: 20144kb
input:
21 1 12 20 120386050 182099280 222752712 222913665 257195402 324758490 382442048 406256231 457956698 467779588 567857336 661061515 728222301 797983727 806341835 868802360 907297649 916281494
output:
560211391
result:
ok 1 number(s): "560211391"
Test #23:
score: 0
Accepted
time: 260ms
memory: 20664kb
input:
21 2 4 6 8 129857468 138172632 145723608 216575771 220505315 295628393 417753389 521498774 521930079 529939110 546550164 646996686 680636133 774918459 802645920 927055494 932188564
output:
981964824
result:
ok 1 number(s): "981964824"
Test #24:
score: 0
Accepted
time: 153ms
memory: 19876kb
input:
21 4 6 8 9 20 136797969 139417914 164970720 223768780 231928019 278498831 340260688 350277118 483857556 584905789 702553546 763661796 860898268 866704419 906203662 948095633
output:
300688102
result:
ok 1 number(s): "300688102"
Test #25:
score: 0
Accepted
time: 138ms
memory: 19712kb
input:
21 2 6 7 9 12 19 130630182 135130250 179860274 191768809 280527244 300297762 302539355 357418035 367165658 415655449 481599984 731631962 766526928 777199793 837857644
output:
190763460
result:
ok 1 number(s): "190763460"
Test #26:
score: 0
Accepted
time: 141ms
memory: 19804kb
input:
21 3 6 11 12 20 20 20 135533018 149425527 221433245 247492671 304122468 404570880 423599606 434664547 578357813 790305774 864606479 879757972 919459861 977522950
output:
761718204
result:
ok 1 number(s): "761718204"
Test #27:
score: 0
Accepted
time: 137ms
memory: 19804kb
input:
21 2 4 5 7 9 9 14 14 122509068 156982362 243205007 244305861 263561256 329493184 569031332 594264883 611234529 618590217 759059448 806091068 979551364
output:
272241629
result:
ok 1 number(s): "272241629"
Test #28:
score: 0
Accepted
time: 150ms
memory: 19776kb
input:
21 1 2 2 7 8 8 10 16 20 167541246 196753990 355567428 388813160 394451146 598659034 756415859 840779873 870064449 903587285 908430826 981579777
output:
993304792
result:
ok 1 number(s): "993304792"
Test #29:
score: 0
Accepted
time: 138ms
memory: 21256kb
input:
21 1 5 7 9 10 12 13 14 17 20 106018219 120744275 210020879 369081638 470845550 574169350 621761408 806151329 922269608 933136766 936649226
output:
158811861
result:
ok 1 number(s): "158811861"
Test #30:
score: 0
Accepted
time: 143ms
memory: 21268kb
input:
21 4 5 5 6 9 10 11 11 11 13 19 171016010 212049293 342459167 465184125 524617335 532940894 549760108 697962892 734123829 860646834
output:
793601692
result:
ok 1 number(s): "793601692"
Test #31:
score: 0
Accepted
time: 128ms
memory: 19988kb
input:
21 1 3 9 9 10 10 11 12 12 14 15 19 212599545 278601073 305382795 563398946 613733490 643863450 729836165 776733467 959863569
output:
794407245
result:
ok 1 number(s): "794407245"
Test #32:
score: 0
Accepted
time: 141ms
memory: 21560kb
input:
21 1 3 7 7 7 12 14 14 15 16 17 17 18 133664733 453952084 579306015 677706872 771632343 842198586 849814998 985234286
output:
41273062
result:
ok 1 number(s): "41273062"
Test #33:
score: 0
Accepted
time: 139ms
memory: 19852kb
input:
21 2 6 7 8 9 11 11 12 13 14 14 15 18 20 314015054 653297629 717189669 728498726 837910922 888628418 984181784
output:
152473669
result:
ok 1 number(s): "152473669"
Test #34:
score: 0
Accepted
time: 132ms
memory: 19740kb
input:
21 2 2 3 6 7 7 9 9 10 13 13 15 15 16 16 218300010 218548568 537527677 717271011 873047851 904535488
output:
766144564
result:
ok 1 number(s): "766144564"
Test #35:
score: 0
Accepted
time: 125ms
memory: 19748kb
input:
21 2 3 4 5 5 8 9 9 11 12 12 13 14 19 19 20 225475265 327047938 557948062 692861769 964450352
output:
63919771
result:
ok 1 number(s): "63919771"
Test #36:
score: 0
Accepted
time: 128ms
memory: 20712kb
input:
21 3 4 4 5 5 6 6 7 9 9 10 11 14 16 17 18 20 241382335 279496067 692314847 756835151
output:
968243564
result:
ok 1 number(s): "968243564"
Test #37:
score: 0
Accepted
time: 128ms
memory: 21340kb
input:
21 1 1 3 3 3 4 6 7 7 8 9 12 12 13 16 19 20 20 131714340 330873949 550704737
output:
331552433
result:
ok 1 number(s): "331552433"
Test #38:
score: 0
Accepted
time: 143ms
memory: 20808kb
input:
21 1 1 1 3 8 8 9 9 11 11 13 13 14 15 15 15 16 18 18 101431998 566611807
output:
496652396
result:
ok 1 number(s): "496652396"
Test #39:
score: 0
Accepted
time: 134ms
memory: 20020kb
input:
21 1 2 2 2 3 3 5 5 6 6 7 8 9 10 10 13 16 16 17 19 469148962
output:
590122358
result:
ok 1 number(s): "590122358"
Test #40:
score: 0
Accepted
time: 130ms
memory: 20668kb
input:
21 999555504 911354638 889343130 702771132 656169624 600578828 558213918 528749384 520183039 514519129 452462885 394955786 383438754 367568798 351352513 340128320 231649055 226724828 160812637 18 3
output:
493749325
result:
ok 1 number(s): "493749325"
Test #41:
score: 0
Accepted
time: 124ms
memory: 20368kb
input:
21 956325037 920511263 905154503 885983922 802244851 736509953 681904836 649055510 634186043 526720970 508936332 479309408 475856778 413328522 295601218 293579350 279703882 259955917 199982142 130431800 18
output:
966007244
result:
ok 1 number(s): "966007244"
Test #42:
score: 0
Accepted
time: 129ms
memory: 19680kb
input:
21 992861843 839155091 834151122 823841531 785757625 784757070 721468976 712314229 692580703 599399596 485031001 438277312 347064849 325745089 238121226 205120654 193758294 188769533 14 11 5
output:
568825101
result:
ok 1 number(s): "568825101"
Test #43:
score: 0
Accepted
time: 140ms
memory: 21536kb
input:
21 996117513 839748601 778560189 678754677 654071684 626197684 567973686 492027025 459427270 327773502 314074272 297493166 267290870 258615320 239757713 161092122 131980196 20 18 15 11
output:
386907963
result:
ok 1 number(s): "386907963"
Test #44:
score: 0
Accepted
time: 126ms
memory: 21268kb
input:
21 984063020 965810495 949550740 890570704 887173134 855655670 761033115 731353875 652995773 518354263 471379690 468303420 455139606 408055422 262807678 107812705 19 19 14 8 1
output:
497331226
result:
ok 1 number(s): "497331226"
Test #45:
score: 0
Accepted
time: 126ms
memory: 20152kb
input:
21 938414998 857006452 825006497 818132245 810779185 752106704 731810609 710908712 702001207 679793862 652608963 567502027 357953850 341173221 176595448 11 8 7 5 3 3
output:
368217679
result:
ok 1 number(s): "368217679"
Test #46:
score: 0
Accepted
time: 135ms
memory: 19816kb
input:
21 945145970 800597255 735410702 706591950 624972104 514070478 485917850 442864095 402586145 293621350 269799030 224292611 200924773 142410246 13 11 11 9 7 5 4
output:
441317824
result:
ok 1 number(s): "441317824"
Test #47:
score: 0
Accepted
time: 129ms
memory: 20844kb
input:
21 938422748 937153023 864570637 854908512 852654148 737439116 713128605 675576784 532211530 501824920 342910291 263202103 179512754 19 17 15 12 10 10 10 5
output:
839537178
result:
ok 1 number(s): "839537178"
Test #48:
score: 0
Accepted
time: 133ms
memory: 19844kb
input:
21 965220836 928544018 776752609 690124778 600069568 518912248 517731989 377873787 315428146 241019488 185314512 110444208 19 12 9 8 6 4 3 2 1
output:
497331226
result:
ok 1 number(s): "497331226"
Test #49:
score: 0
Accepted
time: 135ms
memory: 21248kb
input:
21 959267360 877481412 828524043 773680944 747114367 677588189 651036367 609755574 498077668 286071658 266013389 20 18 16 16 15 13 10 7 6 2
output:
994662452
result:
ok 1 number(s): "994662452"
Test #50:
score: 0
Accepted
time: 120ms
memory: 19684kb
input:
21 986910591 920042458 735022689 655814673 611783988 594018951 316880905 260012404 201114454 175296284 20 16 13 12 10 10 9 9 8 3 3
output:
401069322
result:
ok 1 number(s): "401069322"
Test #51:
score: 0
Accepted
time: 132ms
memory: 19820kb
input:
21 690600507 656280399 489006427 350648665 307850369 254066859 167342116 153562583 120941625 19 18 18 17 16 15 11 9 8 7 3 2
output:
413212129
result:
ok 1 number(s): "413212129"
Test #52:
score: 0
Accepted
time: 128ms
memory: 20468kb
input:
21 957929719 790647185 754573888 740449949 507562672 368087161 323757438 136318185 17 14 13 11 10 9 8 8 5 4 4 3 3
output:
241061925
result:
ok 1 number(s): "241061925"
Test #53:
score: 0
Accepted
time: 124ms
memory: 21664kb
input:
21 778267726 633079841 275416873 254978092 230251233 230046678 123579978 18 18 14 13 12 12 12 11 10 9 7 7 3 1
output:
497331226
result:
ok 1 number(s): "497331226"
Test #54:
score: 0
Accepted
time: 128ms
memory: 21048kb
input:
21 913467850 814010889 794138028 648986910 364413463 305190401 20 16 15 14 13 13 12 11 11 10 9 5 4 2 1
output:
497331226
result:
ok 1 number(s): "497331226"
Test #55:
score: 0
Accepted
time: 132ms
memory: 21124kb
input:
21 869926689 703812957 561426309 163144118 125528408 19 19 16 13 13 12 11 11 9 9 9 8 6 5 4 3
output:
151105920
result:
ok 1 number(s): "151105920"
Test #56:
score: 0
Accepted
time: 138ms
memory: 19700kb
input:
21 833702168 279249090 220459106 143212450 17 16 15 13 13 12 10 10 10 6 6 5 4 3 2 1 1
output:
914125256
result:
ok 1 number(s): "914125256"
Test #57:
score: 0
Accepted
time: 133ms
memory: 19876kb
input:
21 295156160 277579235 202708257 19 19 18 16 14 13 13 13 12 11 10 8 7 5 4 2 1 1
output:
914125256
result:
ok 1 number(s): "914125256"
Test #58:
score: 0
Accepted
time: 129ms
memory: 21360kb
input:
21 311063229 266681639 18 18 17 17 16 16 15 15 13 11 10 9 7 7 4 3 2 1 1
output:
914125256
result:
ok 1 number(s): "914125256"
Test #59:
score: 0
Accepted
time: 132ms
memory: 20356kb
input:
21 213600385 20 20 18 18 17 15 14 11 11 10 9 8 7 7 5 5 4 4 4 1
output:
549018265
result:
ok 1 number(s): "549018265"
Test #60:
score: 0
Accepted
time: 130ms
memory: 19804kb
input:
21 541225109 392096644 981185085 571642649 701572556 819829681 663437504 872433182 767559669 883527420 216585748 584430332 881824970 723688233 483781355 383203364 483035166 634517835 873943053 5 19
output:
973145535
result:
ok 1 number(s): "973145535"
Test #61:
score: 0
Accepted
time: 131ms
memory: 20880kb
input:
21 525318040 381174950 162113641 896858784 188244706 505659757 376986162 636639415 296765557 293520869 577248953 976197708 295118341 824002369 609836775 208486486 511466163 934830325 11 386351091 391122216
output:
545233748
result:
ok 1 number(s): "545233748"
Test #62:
score: 0
Accepted
time: 134ms
memory: 20804kb
input:
21 557132179 5 379389222 768884620 566036345 751152626 261648949 655163454 3 10 682752721 470986368 180199069 537767868 184272464 831533051 366226067 230450586 932732385 601852969 749058949
output:
90344932
result:
ok 1 number(s): "90344932"
Test #63:
score: 0
Accepted
time: 131ms
memory: 21020kb
input:
21 171487289 9 807123809 795784922 860787652 14 758509082 786487593 208284113 481683414 856616383 15 7 275981623 993844859 786569468 135086604 340419524 460738765 628651057 584450674
output:
153607428
result:
ok 1 number(s): "153607428"
Test #64:
score: 0
Accepted
time: 128ms
memory: 21196kb
input:
21 392427068 331866094 871097190 635384508 6 790840564 222670849 8 801839842 843908961 15 7 655449146 350588935 547683607 11 544207429 637219112 383709661 898931889 996319632
output:
671941491
result:
ok 1 number(s): "671941491"
Test #65:
score: 0
Accepted
time: 136ms
memory: 20488kb
input:
21 408334137 11 708232516 890898892 626168830 133805551 792868978 894644225 391202850 240103280 18 13 7 728275015 700542005 19 682247234 269951385 301441424 20 682050392
output:
401072184
result:
ok 1 number(s): "401072184"
Test #66:
score: 0
Accepted
time: 132ms
memory: 21664kb
input:
21 548613023 840153880 314583680 1 638314312 107006645 11 589864682 910661330 878660042 709045323 3 1 9 523606835 426170704 12 203395990 18 717656540 121449886
output:
859919428
result:
ok 1 number(s): "859919428"
Test #67:
score: 0
Accepted
time: 132ms
memory: 19900kb
input:
21 154183267 957430617 1 16 7 297347108 389104909 218440827 298477763 6 102718982 20 10 255816671 940876121 974634712 13 280568406 20 733563609 349141600
output:
497169716
result:
ok 1 number(s): "497169716"
Test #68:
score: 0
Accepted
time: 132ms
memory: 20508kb
input:
21 608242111 707491082 11 343640801 20 1 944762529 15 300506177 634649233 17 20 143088648 967674209 9 688750145 215081403 15 595216165 954503388 12
output:
44647300
result:
ok 1 number(s): "44647300"
Test #69:
score: 0
Accepted
time: 134ms
memory: 21072kb
input:
21 777293768 13 866010071 3 738795316 17 1 498794884 8 10 183741062 379087508 15 872515699 968463365 10 579784498 715138959 13 845715468 12
output:
245107529
result:
ok 1 number(s): "245107529"
Test #70:
score: 0
Accepted
time: 136ms
memory: 20696kb
input:
21 202830149 18 13 106707172 4 18 504748265 14 6 267095051 4 107801405 868038485 888422769 13 981384512 632692092 5 577565459 13 7
output:
734793841
result:
ok 1 number(s): "734793841"
Test #71:
score: 0
Accepted
time: 135ms
memory: 21096kb
input:
21 5 9 656896335 3 5 542229643 18 252163685 254784075 18 15 7 13 904329839 487162265 13 17 738662557 778359455 6 386675830
output:
973591474
result:
ok 1 number(s): "973591474"
Test #72:
score: 0
Accepted
time: 140ms
memory: 20108kb
input:
21 2 4 333554651 559000564 2 189459268 4 19 606163773 5 16 881629137 10 313652240 8 19 6 147365545 440112951 13 15
output:
249385382
result:
ok 1 number(s): "249385382"
Test #73:
score: 0
Accepted
time: 137ms
memory: 19972kb
input:
21 4 10 390204313 8 829914235 211338927 20 9 290955948 353579193 13 329559310 14 6 9 1 321028631 6 12 8 10
output:
512583133
result:
ok 1 number(s): "512583133"
Test #74:
score: 0
Accepted
time: 137ms
memory: 20428kb
input:
21 16 5 455395416 9 111293955 1 18 4 3 3 4 550499088 186929685 524748227 2 14 3 18 12 1 912611991
output:
164811218
result:
ok 1 number(s): "164811218"
Test #75:
score: 0
Accepted
time: 141ms
memory: 20212kb
input:
21 4 9 8 7 6 11 6 589762201 538216630 1 19 859821491 660027411 6 14 8 3 18 7 2 250903066
output:
315278244
result:
ok 1 number(s): "315278244"
Test #76:
score: 0
Accepted
time: 150ms
memory: 19736kb
input:
21 4 5 8 20 5 1 3 11 3 7 12 875728560 929161695 319060207 8 7 7 7 226493824 10 1
output:
735599397
result:
ok 1 number(s): "735599397"
Test #77:
score: 0
Accepted
time: 138ms
memory: 20304kb
input:
21 12 4 17 15 11 19 290467206 17 16 3 7 891635630 3 4 10 15 14 163528479 11 6 13
output:
667891578
result:
ok 1 number(s): "667891578"
Test #78:
score: 0
Accepted
time: 143ms
memory: 20396kb
input:
21 16 12 5 6 19 354440588 10 20 10 6 9 505990740 11 19 4 12 2 10 10 6 9
output:
131101476
result:
ok 1 number(s): "131101476"
Test #79:
score: 0
Accepted
time: 136ms
memory: 20624kb
input:
21 18 1 10 5 10 17 7 12 8 20 18 16 4 810079855 5 4 20 6 18 4 3
output:
891380736
result:
ok 1 number(s): "891380736"
Test #80:
score: 0
Accepted
time: 327ms
memory: 36228kb
input:
22 6 15 268197231 270213508 351452192 492866287 531799755 552239196 566100844 615714555 621750005 623813322 631485861 697499611 720172147 827545453 837938580 852025080 853735774 926374427 980791319 982024848
output:
597142018
result:
ok 1 number(s): "597142018"
Test #81:
score: 0
Accepted
time: 333ms
memory: 36064kb
input:
22 2 162520471 173004431 198239108 244114557 302759893 463934490 480658834 482498884 488145959 511979682 519427102 528616178 555102172 578113708 586853566 597015234 703105915 711785228 721262478 902244192 944531389
output:
979133950
result:
ok 1 number(s): "979133950"
Test #82:
score: 0
Accepted
time: 325ms
memory: 36224kb
input:
22 11 14 15 426013020 454770652 455447536 471085448 504687325 526342634 548569766 562228787 568129258 627501859 631066803 700520580 708634296 719164538 751349368 802362855 853845650 896926015 961912238
output:
6994972
result:
ok 1 number(s): "6994972"
Test #83:
score: 0
Accepted
time: 315ms
memory: 35984kb
input:
22 4 7 8 14 105652325 120355457 172708839 174785427 196279023 268115567 299681118 329285529 331786382 365124962 377739197 383994167 529768966 534831571 653654704 784309498 811618337 847730551
output:
181193197
result:
ok 1 number(s): "181193197"
Test #84:
score: 0
Accepted
time: 305ms
memory: 36236kb
input:
22 3 6 9 12 14 149623537 150284620 184328839 361536658 423651264 484107830 530543907 545121215 572186085 590638986 606102834 615824964 633428898 661542481 721587666 740711226 790647028
output:
729929293
result:
ok 1 number(s): "729929293"
Test #85:
score: 0
Accepted
time: 325ms
memory: 36228kb
input:
22 7 7 7 11 16 16 159919597 211388949 338761097 348829236 355440754 500014899 574692343 642623053 642906328 713617924 872602295 875078011 889884207 960102922 975766458 986611630
output:
204507991
result:
ok 1 number(s): "204507991"
Test #86:
score: 0
Accepted
time: 321ms
memory: 36232kb
input:
22 1 4 5 5 13 15 17 131089105 223892979 314477504 417531672 431556112 515921969 524451085 601190233 619135718 626586033 638618664 669421141 806949638 960297660 977794871
output:
944898006
result:
ok 1 number(s): "944898006"
Test #87:
score: 0
Accepted
time: 307ms
memory: 36092kb
input:
22 1 6 8 10 14 15 15 18 149494299 175537062 199483736 333872312 366551138 448844289 545948376 569083380 736861747 739318309 774790576 785958808 901251939 994750290
output:
887434169
result:
ok 1 number(s): "887434169"
Test #88:
score: 0
Accepted
time: 307ms
memory: 36088kb
input:
22 2 3 5 8 8 12 15 18 18 146184149 154210320 173520864 263457118 408682966 518338958 571786281 583211074 624488092 746693421 774208133 925583936 928050028
output:
332210009
result:
ok 1 number(s): "332210009"
Test #89:
score: 0
Accepted
time: 300ms
memory: 36056kb
input:
22 1 6 7 8 8 8 11 13 15 20 245550822 291183558 316595400 384295897 526522029 590076420 652884922 658971909 665051016 707207275 712157415 719265313
output:
199530962
result:
ok 1 number(s): "199530962"
Test #90:
score: 0
Accepted
time: 306ms
memory: 36184kb
input:
22 1 2 5 11 12 14 15 15 17 17 20 146606768 163316546 191973690 406868660 517340445 599550910 605292604 661000323 680984842 728064484 859082511
output:
116806852
result:
ok 1 number(s): "116806852"
Test #91:
score: 0
Accepted
time: 306ms
memory: 36116kb
input:
22 2 3 4 5 7 8 11 13 16 16 17 20 147369904 170786125 219637448 280973553 282511220 342419595 551999039 629640559 650786981 912311699
output:
443557727
result:
ok 1 number(s): "443557727"
Test #92:
score: 0
Accepted
time: 313ms
memory: 36028kb
input:
22 5 7 7 8 12 15 15 16 16 16 16 17 19 331999869 358326664 361281796 439234373 532975220 620373047 693613941 765620118 905999128
output:
666877738
result:
ok 1 number(s): "666877738"
Test #93:
score: 0
Accepted
time: 308ms
memory: 36064kb
input:
22 3 4 7 8 9 11 11 12 14 15 16 17 17 20 255421401 259572381 311995869 327712205 374233734 669204699 754739832 858447257
output:
329573619
result:
ok 1 number(s): "329573619"
Test #94:
score: 0
Accepted
time: 311ms
memory: 36136kb
input:
22 1 3 3 4 4 7 8 11 12 14 14 16 17 19 20 107414635 194139325 196560473 683556136 733178081 785983810 938638018
output:
322334578
result:
ok 1 number(s): "322334578"
Test #95:
score: 0
Accepted
time: 314ms
memory: 36128kb
input:
22 1 1 2 2 3 4 7 9 9 11 13 14 14 17 18 20 209528623 307216879 476621835 533538819 666447432 916898481
output:
31644183
result:
ok 1 number(s): "31644183"
Test #96:
score: 0
Accepted
time: 306ms
memory: 36084kb
input:
22 2 2 4 4 5 6 6 7 8 8 8 10 11 12 16 17 18 225435692 255642483 413862853 667905605 977774929
output:
873133349
result:
ok 1 number(s): "873133349"
Test #97:
score: 0
Accepted
time: 317ms
memory: 36132kb
input:
22 2 2 2 3 5 6 7 9 11 12 12 13 14 14 17 19 20 20 107305098 241342762 346781019 934663133
output:
504705422
result:
ok 1 number(s): "504705422"
Test #98:
score: 0
Accepted
time: 318ms
memory: 36120kb
input:
22 1 1 2 2 3 4 5 5 8 9 10 11 14 15 16 19 20 20 20 410754401 420268449 550665164
output:
31644183
result:
ok 1 number(s): "31644183"
Test #99:
score: 0
Accepted
time: 311ms
memory: 36060kb
input:
22 2 3 3 4 4 5 6 6 6 7 8 9 12 13 13 15 17 17 19 20 453945260 854754279
output:
512059856
result:
ok 1 number(s): "512059856"
Test #100:
score: 0
Accepted
time: 308ms
memory: 36092kb
input:
22 955554774 947511214 868388188 852765442 809579437 774712774 745855555 710701057 684804116 684434709 679857623 608249326 572869312 547168270 540465908 506531802 438026875 327804063 323988596 211838374 17 8
output:
747925468
result:
ok 1 number(s): "747925468"
Test #101:
score: 0
Accepted
time: 320ms
memory: 36120kb
input:
22 998627382 975297506 969979850 957580773 905783467 902174840 835521050 829230082 746766169 668961783 601554686 592897078 558907767 504967180 494098737 369243715 283778382 231143506 185040286 179878781 116927474 13
output:
716256709
result:
ok 1 number(s): "716256709"
Test #102:
score: 0
Accepted
time: 319ms
memory: 36112kb
input:
22 955482833 908002903 862781884 854840926 809828937 668857474 649179023 647689150 572393660 556372978 506951489 470139166 453196107 443669172 264514057 261661869 250087929 120984301 113502410 12 3 1
output:
592612860
result:
ok 1 number(s): "592612860"
Test #103:
score: 0
Accepted
time: 314ms
memory: 36228kb
input:
22 982345465 947730674 850553262 849430081 706760446 533891213 488778609 470467260 468027157 416051238 317271029 300752716 248954447 226534590 188077354 178835027 156970281 123012715 20 20 12 5
output:
966575594
result:
ok 1 number(s): "966575594"
Test #104:
score: 0
Accepted
time: 316ms
memory: 36136kb
input:
22 998252535 962915683 931214317 894949833 865002268 849393076 716003079 693035731 628450730 526593087 497265349 437531957 332623277 328378196 211109829 146159939 111048250 18 13 10 5 3
output:
485519815
result:
ok 1 number(s): "485519815"
Test #105:
score: 0
Accepted
time: 300ms
memory: 36224kb
input:
22 934019148 827333241 715287840 713474186 668451208 665212687 528621501 485559433 435680814 407574936 407471379 289880404 231325440 218399166 208920588 167977782 19 16 13 9 4 1
output:
592612860
result:
ok 1 number(s): "592612860"
Test #106:
score: 0
Accepted
time: 316ms
memory: 36028kb
input:
22 907577369 888957216 867099022 862904328 824958927 793076696 651957335 530649915 495734055 423482006 317134524 257446193 242210515 170990440 122451295 17 17 14 13 9 9 1
output:
592612860
result:
ok 1 number(s): "592612860"
Test #107:
score: 0
Accepted
time: 338ms
memory: 36056kb
input:
22 974899425 959325712 945869597 911968517 777130053 773287444 747176955 644421784 532678328 489276991 411855357 369895523 267581231 257963306 18 13 12 11 10 7 6 3
output:
423078209
result:
ok 1 number(s): "423078209"
Test #108:
score: 0
Accepted
time: 334ms
memory: 36196kb
input:
22 974032489 953744187 899536615 860806387 695185133 623088213 586776542 556150702 526969396 516075079 428899513 329674033 193692496 20 19 18 16 16 14 13 8 1
output:
592612860
result:
ok 1 number(s): "592612860"
Test #109:
score: 0
Accepted
time: 309ms
memory: 36096kb
input:
22 980404150 903855422 897968774 881481152 863290276 853072170 742483976 726129073 666943437 625519748 456608837 363739313 19 19 16 16 15 14 13 12 11 4
output:
720569023
result:
ok 1 number(s): "720569023"
Test #110:
score: 0
Accepted
time: 325ms
memory: 36064kb
input:
22 982625997 935949527 854846397 759424799 540513948 472515907 412241305 387770057 292471663 253051747 160735017 16 15 15 14 11 11 8 6 4 4 2
output:
712875610
result:
ok 1 number(s): "712875610"
Test #111:
score: 0
Accepted
time: 328ms
memory: 36184kb
input:
22 999922909 986871019 861192335 679974423 659844613 557143400 538445448 426838448 287929369 170986673 19 18 16 16 16 15 15 14 13 10 5 1
output:
592612860
result:
ok 1 number(s): "592612860"
Test #112:
score: 0
Accepted
time: 324ms
memory: 36120kb
input:
22 962921154 924050765 846962166 770480958 738615189 561205233 560787957 500312430 102778087 20 20 17 17 17 16 14 13 10 10 7 2 1
output:
592612860
result:
ok 1 number(s): "592612860"
Test #113:
score: 0
Accepted
time: 326ms
memory: 36064kb
input:
22 950589241 703071413 665218157 594377586 232267814 205637435 139487048 118685157 16 16 16 16 13 12 11 10 10 10 6 5 3 3
output:
790002885
result:
ok 1 number(s): "790002885"
Test #114:
score: 0
Accepted
time: 321ms
memory: 36104kb
input:
22 810045098 687124771 440390524 428007559 340004220 257638530 253410382 20 20 17 17 15 15 14 13 13 10 5 4 3 3 1
output:
592612860
result:
ok 1 number(s): "592612860"
Test #115:
score: 0
Accepted
time: 325ms
memory: 36232kb
input:
22 695793094 684561205 679403715 648947338 261112711 179051187 20 20 20 19 19 18 14 13 11 7 6 6 4 4 3 2
output:
77343496
result:
ok 1 number(s): "77343496"
Test #116:
score: 0
Accepted
time: 336ms
memory: 36188kb
input:
22 869887116 813770500 646718028 448057278 354825891 19 19 18 16 16 15 15 15 14 13 10 10 9 8 8 7 5
output:
91471775
result:
ok 1 number(s): "91471775"
Test #117:
score: 0
Accepted
time: 332ms
memory: 36112kb
input:
22 425738676 423648036 341552617 279209518 20 18 16 15 14 13 12 12 10 7 5 4 3 2 1 1 1 1
output:
964410584
result:
ok 1 number(s): "964410584"
Test #118:
score: 0
Accepted
time: 327ms
memory: 36192kb
input:
22 487621418 295116587 204759325 20 19 18 18 17 15 15 15 14 14 14 12 11 10 8 3 2 1 1
output:
298538448
result:
ok 1 number(s): "298538448"
Test #119:
score: 0
Accepted
time: 314ms
memory: 36060kb
input:
22 599205702 150053513 20 19 18 16 13 12 11 10 10 9 9 9 8 6 6 4 3 2 1 1
output:
298538448
result:
ok 1 number(s): "298538448"
Test #120:
score: 0
Accepted
time: 327ms
memory: 36228kb
input:
22 345654998 2 327236741 683821974 579686121 373760221 326515402 605280443 178442576 129273610 970764945 285626376 705902664 309298083 11 846814912 214291747 926609681 460942071 940728201 855919630 601168289
output:
761195702
result:
ok 1 number(s): "761195702"
Test #121:
score: 0
Accepted
time: 311ms
memory: 36116kb
input:
22 291744295 14 120502650 506177394 187493658 181891504 378941076 696809879 462882195 441093651 793594762 839167217 185361580 591500352 176414162 971140788 932564180 146228594 738400749 228876724 652832314 174931298
output:
291134056
result:
ok 1 number(s): "291134056"
Test #122:
score: 0
Accepted
time: 319ms
memory: 36228kb
input:
22 446122545 993144376 281983124 699422650 15 300978625 754247822 479241147 561176559 564753099 648697577 850743355 16 361052799 489679230 6 875438282 633464027 753438077 993451304 224925720 954818303
output:
57343870
result:
ok 1 number(s): "57343870"
Test #123:
score: 0
Accepted
time: 318ms
memory: 36084kb
input:
22 838279960 485734318 10 472920633 706695952 692756705 376641266 988097071 189312836 340544638 733838952 243662968 895483770 280360752 17 605808854 654131590 109051445 806265456 10 877466695 20
output:
493254997
result:
ok 1 number(s): "493254997"
Test #124:
score: 0
Accepted
time: 332ms
memory: 36124kb
input:
22 15 219444267 410694892 160696039 222463856 499718722 390057881 525313213 692613999 445408440 3 264489859 124958514 620539829 455411841 586079776 100698759 215033036 4 7 14 966399957
output:
397571287
result:
ok 1 number(s): "397571287"
Test #125:
score: 0
Accepted
time: 335ms
memory: 36060kb
input:
22 979975318 561863350 328463241 16 607832407 220147205 241565028 9 128633080 639313626 233101477 925352577 693432208 588108190 9 2 8 732654144 5 113144168 132630457 297387593
output:
871482275
result:
ok 1 number(s): "871482275"
Test #126:
score: 0
Accepted
time: 328ms
memory: 36080kb
input:
22 677485566 259899566 10 903363823 655220695 758024860 2 20 6 185059567 211401033 498132638 385103894 124607613 17 602133434 658188644 696230135 467144256 14 2 304053999
output:
57794836
result:
ok 1 number(s): "57794836"
Test #127:
score: 0
Accepted
time: 311ms
memory: 36092kb
input:
22 671127765 393165106 405462350 376126832 491730364 387132308 16 16 284947534 10 20 368027381 11 163090882 135629628 151084463 419592386 1 864207200 788619650 3 7
output:
718091323
result:
ok 1 number(s): "718091323"
Test #128:
score: 0
Accepted
time: 316ms
memory: 36120kb
input:
22 606207395 11 842111531 498774077 4 8 18 1 790712681 518528452 842066180 563411746 13 172422933 10 782966390 773592474 395002785 687034834 6 105285542 18
output:
215815586
result:
ok 1 number(s): "215815586"
Test #129:
score: 0
Accepted
time: 314ms
memory: 36064kb
input:
22 17 201091887 414961101 16 17 959735094 7 16 19 9 15 768888792 611840668 933784586 132436746 446503639 922200081 597631775 760959679 285114961 10 5
output:
375642605
result:
ok 1 number(s): "375642605"
Test #130:
score: 0
Accepted
time: 333ms
memory: 36080kb
input:
22 11 302478692 639115050 987433059 416989514 5 5 19 104877999 471185795 667443418 471836240 14 1 5 9 123708475 983343213 5 665739969 12 7
output:
360206597
result:
ok 1 number(s): "360206597"
Test #131:
score: 0
Accepted
time: 320ms
memory: 36028kb
input:
22 14 591563179 8 486077977 2 7 758861738 683350487 811235734 16 2 981499342 15 20 4 187681857 162113788 477234342 9 15 876963549 19
output:
477598456
result:
ok 1 number(s): "477598456"
Test #132:
score: 0
Accepted
time: 323ms
memory: 36096kb
input:
22 945563267 3 760519991 5 14 945602519 163272615 7 19 16 1 18 15 16 579260552 867035626 739332405 8 12 218033360 6 699257557
output:
787042584
result:
ok 1 number(s): "787042584"
Test #133:
score: 0
Accepted
time: 315ms
memory: 36132kb
input:
22 20 14 385002012 10 227245996 7 11 15 6 938371369 4 4 985038306 246125306 3 692978687 15 9 108579958 10 1 561869618
output:
713506666
result:
ok 1 number(s): "713506666"
Test #134:
score: 0
Accepted
time: 304ms
memory: 36188kb
input:
22 17 15 925145956 20 10 7 3 1 3 4 16 345086234 465294043 14 3 202836754 329519737 17 519368797 146978775 17 9
output:
632576201
result:
ok 1 number(s): "632576201"
Test #135:
score: 0
Accepted
time: 312ms
memory: 36120kb
input:
22 14 19 16 13 5 9 266810136 7 5 6 1 345426806 5 704166605 999426905 858768292 19 6 490664760 16 7 7
output:
174071277
result:
ok 1 number(s): "174071277"
Test #136:
score: 0
Accepted
time: 313ms
memory: 36180kb
input:
22 3 8 1 189771921 18 535816227 654749209 3 17 298167785 1 453426992 15 14 13 18 6 16 11 7 12 10
output:
292876553
result:
ok 1 number(s): "292876553"
Test #137:
score: 0
Accepted
time: 325ms
memory: 36064kb
input:
22 8 15 12 670656278 7 20 432534570 15 9 16 16 13 5 16 868792570 306374275 10 13 10 1 15 10
output:
288694679
result:
ok 1 number(s): "288694679"
Test #138:
score: 0
Accepted
time: 314ms
memory: 36184kb
input:
22 18 16 9 647813219 16 9 6 12 9 18 15 6 18 1 780413075 3 8 13 17 891596057 3 11
output:
430842549
result:
ok 1 number(s): "430842549"
Test #139:
score: 0
Accepted
time: 321ms
memory: 36096kb
input:
22 7 12 17 13 16 20 589100504 681490031 4 10 9 9 13 9 2 9 15 15 13 10 19 12
output:
872714864
result:
ok 1 number(s): "872714864"