QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#630108 | #9440. Train Seats | HuTao | AC ✓ | 289ms | 73152kb | C++14 | 3.8kb | 2024-10-11 16:31:55 | 2024-10-11 16:31:56 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
const int N = 2e5 + 5, M = 8e5 + 5;
int n, m, a[N], b[N];
struct Frac{
LL a, b;
Frac() {}
Frac(LL _a, LL _b) : a(_a), b(_b) {}
inline bool operator <(const Frac &w) const
{
return (__int128)a * w.b < (__int128)b * w.a;
}
inline bool operator ==(const Frac &w) const
{
return (__int128)a * w.b == (__int128)b * w.a;
}
};
struct Block{
Frac val;
LL s;
};
Block sta[N];
int tt;
Frac xx[M];
int ss;
vector<Block> dl[N], dr[N];
struct Node{
int a, b;
LL cnt, sum, v;
}t[M * 4];
int pos[M];
LL sum, ans;
inline void Get()
{
for(int i = 1; i <= n; i ++ )
{
LL s = b[i], c = 1, x = b[i];
while(tt && Frac(s, c) < sta[tt].val)
{
x += s * sta[tt].val.b + sta[tt].s;
s += sta[tt].val.a, c += sta[tt].val.b;
dl[i].push_back({sta[tt].val, -sta[tt].s});
tt -- ;
}
// printf("!!%lld %lld %lld\n", s, c, x);
sta[ ++ tt] = /**/ {{s, c}, x};
xx[ ++ ss] = /**/ {s, c};
dl[i].push_back(sta[tt]);
// printf("#%d\n", i);
// for(int i = 1; i <= tt; i ++ ) printf("(%lld %lld %lld) ", sta[i].val.a, sta[i].val.b, sta[i].s);
// puts("");
}
tt = 0;
for(int i = n + 1; i > 1; i -- )
{
LL s = b[i], c = 1, x = b[i];
while(tt && Frac(s, c) < sta[tt].val)
{
// printf("**%lld %lld %lld\n", sta[tt].val.a, sta[tt].val.b, s);
x += s * sta[tt].val.b + sta[tt].s;
s += sta[tt].val.a, c += sta[tt].val.b;
dr[i].push_back(sta[tt]);
tt -- ;
}
// printf("*%d %lld\n", i, x);
sta[ ++ tt] = /**/ {{s, c}, x};
xx[ ++ ss] = /**/ {s, c};
dr[i].push_back({sta[tt].val, -sta[tt].s});
}
}
inline void Hash()
{
sort(xx + 1, xx + ss + 1);
ss = unique(xx + 1, xx + ss + 1) - xx - 1;
// for(int i = 1; i <= ss; i ++ ) printf("(%lld %lld) ", xx[i].a, xx[i].b);
// puts("");
}
inline int Find(Frac &x)
{
return lower_bound(xx + 1, xx + ss + 1, x) - xx;
}
#define ls (u << 1)
#define rs (u << 1 | 1)
inline void PushUp(int u)
{
t[u].cnt = t[ls].cnt + t[rs].cnt;
t[u].sum = t[ls].sum + t[rs].sum;
t[u].v = t[ls].v + t[rs].v + t[rs].sum * t[ls].cnt;
}
inline void Build(int u, int a, int b)
{
t[u].a = a, t[u].b = b;
if(a == b) pos[a] = u;
else
{
int mid = (a + b) >> 1;
Build(ls, a, mid);
Build(rs, mid + 1, b);
}
}
inline void Modify(int x, LL dc, LL ds)
{
int u = pos[x];
if(dc > 0) t[u].v += t[u].cnt * ds;
t[u].cnt += dc, t[u].sum += ds;
if(dc < 0) t[u].v += t[u].cnt * ds;
// printf("!%d %lld %lld %lld\n", x, t[u].cnt, t[u].sum, t[u].v);
for(u >>= 1; u; u >>= 1) PushUp(u);
}
inline void Work()
{
Build(1, 1, ss);
for(int i = 1; i <= tt; i ++ )
{
sum += sta[i].s;
Modify(Find(sta[i].val), sta[i].val.b, sta[i].val.a);
// printf("!!%lld %lld %lld\n", sta[i].val.a, sta[i].val.b, sta[i].s);
}
ans = sum + t[1].v + 1LL * n * b[1];
// printf("#%lld %lld %lld\n", sum + t[1].v + 1LL * n * b[1], sum, t[1].v);
for(int j = 2; j <= n + 1; j ++ )
{
for(Block &i : dr[j])
{
// printf("!%lld %lld %lld\n", i.val.a, i.val.b, i.s);
sum += i.s;
if(i.s > 0) Modify(Find(i.val), i.val.b, i.val.a);
else Modify(Find(i.val), -i.val.b, -i.val.a);
}
for(Block &i : dl[j - 1])
{
// printf("!%lld %lld %lld\n", i.val.a, i.val.b, i.s);
sum += i.s;
if(i.s > 0) Modify(Find(i.val), i.val.b, i.val.a);
else Modify(Find(i.val), -i.val.b, -i.val.a);
}
ans = max(ans, sum + t[1].v + 1LL * n * b[j]);
// printf("#%lld %lld %lld\n", sum + t[1].v + 1LL * n * b[j], sum, t[1].v);
}
}
int main()
{
scanf("%d%d", &n, &m);
for(int i = 1; i <= n; i ++ ) scanf("%d", &a[i]);
sort(a + 1, a + n + 1);
for(int i = 1; i <= n; i ++ ) b[i] = a[i] - a[i - 1];
b[n + 1] = m + 1 - a[n];
Get(), Hash(), Work();
printf("%lld\n", ans);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 18168kb
input:
3 10 3 7 10
output:
28
result:
ok "28"
Test #2:
score: 0
Accepted
time: 0ms
memory: 20300kb
input:
5 20 3 10 11 14 17
output:
73
result:
ok "73"
Test #3:
score: 0
Accepted
time: 0ms
memory: 18184kb
input:
10 1000000000 136909656 243332691 643531997 505919307 43553384 657638276 57213246 179732866 357373203 182482400
output:
7649951260
result:
ok "7649951260"
Test #4:
score: 0
Accepted
time: 4ms
memory: 16188kb
input:
1 172024959 118390965
output:
172024960
result:
ok "172024960"
Test #5:
score: 0
Accepted
time: 2ms
memory: 16248kb
input:
2 920065252 24963998 580538879
output:
1815166508
result:
ok "1815166508"
Test #6:
score: 0
Accepted
time: 2ms
memory: 20300kb
input:
3 172078788 90217996 89200357 170380183
output:
432676968
result:
ok "432676968"
Test #7:
score: 0
Accepted
time: 0ms
memory: 20300kb
input:
4 440425711 125318960 91140311 293637977 102491554
output:
1442752023
result:
ok "1442752023"
Test #8:
score: 0
Accepted
time: 0ms
memory: 20308kb
input:
5 322827483 22471802 47973794 3707067 27640905 273307033
output:
1512343852
result:
ok "1512343852"
Test #9:
score: 0
Accepted
time: 0ms
memory: 20176kb
input:
72 630313504 112329946 338670434 45608233 444381955 513206139 543955969 420916952 485920423 598657953 568525637 92887514 375155749 230002387 302266710 539300386 433464422 380969627 445990156 239073197 278937451 50602251 494375406 139348725 11780176 601670777 68418714 591190755 96719555 612628609 778...
output:
25015466409
result:
ok "25015466409"
Test #10:
score: 0
Accepted
time: 0ms
memory: 20360kb
input:
329 622872382 466743684 193969647 525632934 606824701 316078927 438757174 233370039 439667269 218116839 576709355 236207004 276080894 134588177 219271021 277834775 122503124 362333426 562156413 239350876 305538683 46542992 134113566 544875762 187990348 238185200 108286882 14195584 72219185 201093220...
output:
112658144244
result:
ok "112658144244"
Test #11:
score: 0
Accepted
time: 0ms
memory: 16108kb
input:
466 548717850 137350238 67864907 220098233 250261453 342576815 243581822 338228115 183596199 528465164 359278993 293047272 123476508 56052861 140575524 199877484 444249401 72918904 385030174 254594713 77408477 394580770 516234 43634181 69922431 242790597 404250987 350299611 241437643 498603545 12825...
output:
131683312409
result:
ok "131683312409"
Test #12:
score: 0
Accepted
time: 0ms
memory: 16308kb
input:
420 654188648 643476053 366651301 14641834 645843832 522679034 389570065 308006504 72798889 117904764 201972939 507593839 583514089 220780103 413532099 317370571 41515071 21273376 376539882 192798942 426200421 315080562 508007200 611512672 349756948 8346865 179096792 640192856 199017246 126783463 84...
output:
145704451100
result:
ok "145704451100"
Test #13:
score: 0
Accepted
time: 0ms
memory: 20256kb
input:
311 718955427 120599142 231915699 197402685 379093840 587232561 190030463 189278508 87227087 511068641 683198896 398599791 333700658 509210465 251205035 303752755 62480921 208610800 643685861 131513443 704144110 164086927 668251098 187784010 663686098 682516316 68679577 218094403 163030528 178960994...
output:
115142113813
result:
ok "115142113813"
Test #14:
score: 0
Accepted
time: 0ms
memory: 20172kb
input:
56 56 12 48 49 18 4 31 33 38 54 9 53 43 5 23 6 22 47 28 29 36 44 27 50 37 7 25 45 32 11 16 21 15 13 39 14 52 24 34 55 40 20 10 1 35 56 41 19 8 26 30 2 46 3 42 51 17
output:
1652
result:
ok "1652"
Test #15:
score: 0
Accepted
time: 5ms
memory: 20228kb
input:
292 292 64 2 85 65 241 135 29 289 176 34 91 286 42 126 118 92 113 169 200 52 245 9 63 229 15 121 111 190 95 1 78 261 161 224 186 131 149 61 110 177 246 94 221 168 163 141 96 54 155 174 27 237 90 49 272 98 265 122 21 139 228 130 36 12 219 218 258 43 140 222 178 226 51 213 86 194 284 253 62 87 107 23 ...
output:
43070
result:
ok "43070"
Test #16:
score: 0
Accepted
time: 0ms
memory: 20292kb
input:
11 11 11 3 7 8 5 6 1 10 9 4 2
output:
77
result:
ok "77"
Test #17:
score: 0
Accepted
time: 2ms
memory: 20268kb
input:
500 347765135 260493149 25067597 113008832 218516117 56280657 113832119 157268299 330659722 46366527 283273476 225920745 100653375 280745153 292760144 264522189 10282705 52285293 218967533 224892436 92109113 34627737 111139309 255293918 237984629 30990945 328245143 305557032 190718018 11077534 49562...
output:
90441214154
result:
ok "90441214154"
Test #18:
score: 0
Accepted
time: 0ms
memory: 20368kb
input:
500 301750678 276696486 240287710 59135957 203931095 121878437 201932396 119903481 266343627 299466442 29020479 62156629 287057498 236841236 63227599 176195109 143276865 224442819 28959551 267437933 81076858 219733081 269874799 158211607 118629155 94604655 3369831 80540184 49133180 134099302 2299975...
output:
79145246079
result:
ok "79145246079"
Test #19:
score: 0
Accepted
time: 4ms
memory: 16264kb
input:
500 769039012 593481099 47213811 725289908 357593680 269699082 164340753 172703981 688500832 493990088 262289974 204519272 635799158 331303116 247500823 405748889 394512278 272667146 450405422 198279142 642469694 551828186 137495279 125088488 484290075 527122296 634529483 226941356 633400406 3037120...
output:
199483493522
result:
ok "199483493522"
Test #20:
score: 0
Accepted
time: 0ms
memory: 16324kb
input:
500 17243356 4274345 7159636 16001714 5999929 7882069 3863904 8403308 6277018 2113728 16415881 10604344 13348172 13185843 5885601 782788 11403901 4676051 15968455 6831226 9470810 1753743 3472425 4971780 2909875 682610 10262226 2302856 13712204 13418586 8788713 4152278 207883 15901198 9675943 2756881...
output:
4460790428
result:
ok "4460790428"
Test #21:
score: 0
Accepted
time: 0ms
memory: 18324kb
input:
500 558437765 337125873 51347917 529146027 97202740 316090725 497387777 91930764 142324891 213899399 300360595 217018886 166008137 278239234 390780371 40066095 528572067 478181022 316167534 6880776 541827838 518099198 288097089 347164357 238053014 158325454 130726655 292865844 167013716 407014258 47...
output:
142685591676
result:
ok "142685591676"
Test #22:
score: 0
Accepted
time: 0ms
memory: 20744kb
input:
2814 48592630 16511977 39190822 15371231 44199295 13875763 5979234 44459422 34488266 24890518 32006062 18847062 18614807 46663766 39611882 46277006 2340370 41098927 9775227 19526835 4149963 40975662 39987244 29391972 37292663 33830653 42775184 2698281 16075948 15127541 38689879 31070554 41646403 233...
output:
70807645840
result:
ok "70807645840"
Test #23:
score: 0
Accepted
time: 6ms
memory: 20584kb
input:
2052 350095117 203579427 38369113 288330260 37534723 344776523 200360887 327579695 101907902 126659643 103985677 324854168 147450628 320056313 127038766 180892787 78841178 180152606 179893111 87831533 77845834 95798192 291304099 265697769 293531694 122371620 314146836 68374267 276556448 68280635 820...
output:
370125467171
result:
ok "370125467171"
Test #24:
score: 0
Accepted
time: 3ms
memory: 20476kb
input:
1469 255290094 231124406 18714876 85064516 20024565 179469665 150821978 201135927 141805103 232629049 43708592 2539705 51456309 219260250 224324967 28043751 89384614 216927478 25335658 139761855 31817838 160443531 64678209 158095290 44400339 90818688 159767760 130804982 110658789 126330339 8141312 1...
output:
194714283585
result:
ok "194714283585"
Test #25:
score: 0
Accepted
time: 4ms
memory: 18328kb
input:
630 616939669 408782869 248515354 143307241 231934126 370874608 88715805 340086647 216515214 256581727 562593823 40500538 406750476 395927064 485455822 585447257 563193680 460691661 438303133 88948694 492371629 74016447 50330908 136326604 450167882 306959412 353931524 553814973 42315719 348705693 21...
output:
200801304164
result:
ok "200801304164"
Test #26:
score: 0
Accepted
time: 0ms
memory: 16580kb
input:
2619 192078454 58059164 150718520 31723650 85996292 168050293 1245267 161268788 144992340 1769700 148212777 150126107 178409609 46707895 152390448 11364945 131003460 105302051 133594996 17683695 165826229 118954991 9573925 15262066 141461141 40208877 163950812 112422045 77864539 127930840 139571739 ...
output:
256886227046
result:
ok "256886227046"
Test #27:
score: 0
Accepted
time: 0ms
memory: 20528kb
input:
2785 2785 2228 986 299 1148 566 2499 221 1006 2695 1277 1329 2729 662 911 2238 1367 429 2302 1307 2671 2430 2025 1463 2401 2765 805 634 1471 2209 506 2051 1854 84 774 28 1414 1791 2272 1086 1155 425 2716 326 1280 380 462 1674 201 1398 1102 943 1516 1379 1981 501 74 1394 1473 2460 12 1120 2231 2004 2...
output:
3882290
result:
ok "3882290"
Test #28:
score: 0
Accepted
time: 0ms
memory: 20544kb
input:
2994 2994 621 2646 1318 1753 1780 2481 2777 986 373 2620 179 2760 2009 2443 2785 1286 1751 2516 2860 1099 1897 2117 1255 2666 518 1795 2669 2936 2672 406 2752 2825 2527 2088 2206 388 1291 907 539 660 1654 1221 1749 112 435 1763 225 2892 2957 2749 1449 487 2272 26 1190 65 2053 727 1575 2984 2824 1999...
output:
4486509
result:
ok "4486509"
Test #29:
score: 0
Accepted
time: 2ms
memory: 20464kb
input:
2852 2852 1395 298 497 21 1344 554 2350 1081 2431 239 2618 1751 1209 2192 941 1391 2571 1150 745 2477 1308 2832 2540 1293 2174 1420 348 2383 665 1073 1421 779 2648 419 2784 2684 140 2443 188 2481 1168 1717 2133 1246 2286 631 36 2550 573 2419 173 720 260 2766 2148 1752 1517 1541 2845 1175 1784 855 23...
output:
4071230
result:
ok "4071230"
Test #30:
score: 0
Accepted
time: 5ms
memory: 20380kb
input:
1580 1580 514 623 529 580 422 972 1272 653 663 1487 273 768 1115 32 1307 955 183 255 189 1351 1484 1531 769 1407 1415 643 1305 618 1151 862 710 368 1155 337 633 1393 709 408 105 967 1382 538 593 1217 423 411 809 1359 752 634 838 518 499 1446 173 560 1404 1185 496 332 1149 308 1093 339 543 943 935 57...
output:
1250570
result:
ok "1250570"
Test #31:
score: 0
Accepted
time: 0ms
memory: 20428kb
input:
1503 1503 946 1196 1233 837 1006 922 643 240 353 1401 806 1095 1033 1262 1224 1489 206 435 659 1434 597 467 186 827 480 370 1392 938 399 1282 1279 784 159 892 1346 147 841 918 291 179 800 1157 1219 933 1208 56 1060 401 1470 590 902 749 1024 932 351 292 410 891 1471 1246 377 1452 505 1152 204 867 394...
output:
1131759
result:
ok "1131759"
Test #32:
score: 0
Accepted
time: 0ms
memory: 22776kb
input:
3000 427939909 395783930 44089616 259830823 129686735 177460303 393334746 354335948 108616854 254651510 149426746 25596840 284376533 388904805 349010532 122189406 82357545 105555998 185363803 206894621 302592323 127836987 361608374 307482395 325538028 353393412 264670570 61358069 157231515 242862907...
output:
660355238551
result:
ok "660355238551"
Test #33:
score: 0
Accepted
time: 7ms
memory: 20764kb
input:
3000 91550048 28702709 4524831 90599407 73637433 30083293 27295118 3686573 17290403 70504811 17068458 36955403 74000993 33946704 31568496 21102992 60054372 50895890 86513760 21410736 45227468 40803014 87843204 4098854 19621644 29496554 41994490 70749667 54653233 4962828 82527016 64390726 91385906 37...
output:
141727072725
result:
ok "141727072725"
Test #34:
score: 0
Accepted
time: 0ms
memory: 18644kb
input:
3000 690943590 155567311 654690544 391505748 96431566 142447857 605308077 21725534 107818002 327836389 459093331 663442759 128138289 638499436 100007848 580998397 141573702 155305873 690735787 479359122 80471892 62829607 163903295 18430136 195301585 231002740 678326245 429208602 80184947 129435107 2...
output:
1057845234335
result:
ok "1057845234335"
Test #35:
score: 0
Accepted
time: 0ms
memory: 20728kb
input:
3000 401140982 238551737 167321280 283540549 347216637 5774145 268791833 84809226 53641114 252192909 42063769 396334785 172329955 300770949 185494230 99653287 109110515 315136903 270308940 28582978 192144068 35717665 44377222 153079651 159895767 342389398 373894078 32049511 110295212 228872369 18858...
output:
609991741497
result:
ok "609991741497"
Test #36:
score: 0
Accepted
time: 3ms
memory: 16556kb
input:
3000 975913934 906539836 606872628 483668516 726153265 449393411 530059224 692792999 655043845 295086576 792340166 205909076 838159529 9337182 433766692 140663904 82526104 93197284 136517744 291945814 796892136 763552348 460836403 409375003 202832578 869824999 26899716 738871202 381162279 190358087 ...
output:
1493053067773
result:
ok "1493053067773"
Test #37:
score: 0
Accepted
time: 7ms
memory: 22804kb
input:
3000 345501957 97830076 281432665 188896184 111590916 224115766 116648461 2124963 42558746 195012322 33624507 161210125 164937243 25549057 138926863 298372882 339105328 216518801 328410971 145202167 59589159 258916712 86117047 175182013 160040693 104562620 340251571 335072262 16855328 52730532 20290...
output:
530930184383
result:
ok "530930184383"
Test #38:
score: 0
Accepted
time: 3ms
memory: 16508kb
input:
3000 617929357 198249810 573460786 304092958 237446888 243112710 75651657 481078660 142781618 314684673 336068900 62555926 391785047 406454611 195611653 33320505 586381896 88302825 429809337 350493073 69824435 219347533 9107676 358684688 386459236 515199373 265782357 569400396 367056444 567298822 48...
output:
952185007084
result:
ok "952185007084"
Test #39:
score: 0
Accepted
time: 7ms
memory: 22764kb
input:
3000 767871813 76433021 328440878 95050613 496738430 448761654 332237192 631765452 118171788 36141882 728119538 478815048 662906626 331810220 194233196 217533187 355922544 547959993 715826064 523037995 404483309 693608443 77892585 628289311 152776168 332423281 439680891 721519010 129835248 402056500...
output:
1176606785939
result:
ok "1176606785939"
Test #40:
score: 0
Accepted
time: 0ms
memory: 22748kb
input:
3000 357471690 323844979 43089349 114715937 298750312 90110382 31474466 349224938 293958346 168817200 267405782 9138495 16359309 123097183 189782828 230627262 41305824 89498124 113203909 237979594 47558713 171541059 233461023 53357393 62220874 234315611 22116018 168846187 285413503 202599205 1828392...
output:
549109299299
result:
ok "549109299299"
Test #41:
score: 0
Accepted
time: 7ms
memory: 22636kb
input:
3000 741877033 400239912 107588797 560383882 381849771 553961585 127877751 459084191 482969763 675388064 380282041 125472296 496285420 740288363 551762993 402453238 713537429 548634756 192676423 39742778 432314285 58987134 267748998 681918275 222408010 610858741 169529570 305552355 35602580 42688969...
output:
1136617271941
result:
ok "1136617271941"
Test #42:
score: 0
Accepted
time: 231ms
memory: 57704kb
input:
186924 60981890 25028913 7126148 38841403 52621109 1984918 53851519 29560891 40090430 5265610 39758233 5236715 45311009 44791015 1921447 53389131 48251712 36050601 51787553 16678774 15489156 54186341 42225316 41563616 57844881 54569155 8073104 41586507 18170591 5886273 34630027 48582327 41359535 123...
output:
5708759096695
result:
ok "5708759096695"
Test #43:
score: 0
Accepted
time: 267ms
memory: 70760kb
input:
198391 289484296 256629553 82761262 25251714 75012715 71005866 43390943 94377442 93113566 122695246 99191791 54983468 34179944 26434401 197100383 144198841 115813550 285870775 266320310 178205820 25722196 258620333 78553673 136642306 132328421 191735712 156342409 133858702 82191140 203050038 4190225...
output:
28815301599596
result:
ok "28815301599596"
Test #44:
score: 0
Accepted
time: 32ms
memory: 30280kb
input:
29232 828072561 119626257 618882282 175860584 251541464 148019118 801308120 638593639 92553904 84298903 154906129 321738859 265907287 77669154 598942478 294174841 452967219 540181762 344042750 561934056 284400266 328925186 250218747 351027474 141201013 220672773 542842986 489205238 815302120 6800253...
output:
12134633314907
result:
ok "12134633314907"
Test #45:
score: 0
Accepted
time: 95ms
memory: 40760kb
input:
72530 446501809 156495755 115982466 286139733 63269912 91623605 310973418 129326174 362376564 145562583 159107117 30875583 203929196 47489826 202740933 358074442 12741793 95459443 236767416 156198617 276695639 387656292 428880357 60734021 181424863 67587330 187224289 254452538 367022782 335324250 42...
output:
16251496371205
result:
ok "16251496371205"
Test #46:
score: 0
Accepted
time: 82ms
memory: 37036kb
input:
63945 530077287 326266179 208074188 86105271 478959465 133042884 417068174 122008722 375720907 353017783 482626865 37529829 519785502 451878586 319171046 195599327 139460446 122562070 424217390 429607847 146643894 245917657 263069968 95684877 129190288 396754441 465025975 153165148 67168332 31095829...
output:
17003732884692
result:
ok "17003732884692"
Test #47:
score: 0
Accepted
time: 56ms
memory: 28400kb
input:
41862 208882530 71155310 172157744 25892906 80957434 142494457 204080060 170276003 95900528 102507401 132586272 42200826 100475255 39712971 112938337 135018691 99054326 153690823 180745581 180846607 47480413 191461058 91448113 179281361 40414878 96811653 84072481 22265369 207239525 115555177 1148346...
output:
4403244733504
result:
ok "4403244733504"
Test #48:
score: 0
Accepted
time: 189ms
memory: 59200kb
input:
133978 349389124 81919489 141002802 228063078 136925855 286303428 15211816 185487357 134285794 213746384 169660962 258588082 339136579 266226459 163905252 317261684 72581533 241773190 279063620 281968425 82200115 171353978 142851503 103000158 158620510 201638737 248082433 192449004 88320899 25343471...
output:
23489819717007
result:
ok "23489819717007"
Test #49:
score: 0
Accepted
time: 32ms
memory: 37376kb
input:
153445 153445 71000 62860 122934 135523 62615 151179 309 123013 74346 144725 20576 57659 81932 122389 65209 147912 4227 140901 4018 62787 100856 74108 76017 102627 49623 97957 66809 19840 51044 64925 14226 100494 36939 96802 26132 68881 70762 97026 29810 102655 12556 132771 98292 62185 33961 17709 5...
output:
11772914180
result:
ok "11772914180"
Test #50:
score: 0
Accepted
time: 17ms
memory: 27856kb
input:
64545 64545 38944 29049 11027 41795 4270 4500 41961 53429 41761 57245 27727 4619 55561 5830 40031 32468 49578 1869 51699 47977 23968 53027 33942 43183 22932 53315 42844 16806 57633 38641 48998 8228 59388 39163 30055 26346 34510 38853 3040 22006 9657 48747 18574 892 1584 32740 23729 13138 24277 57278...
output:
2083125330
result:
ok "2083125330"
Test #51:
score: 0
Accepted
time: 49ms
memory: 40520kb
input:
193222 193222 110066 164556 186509 141799 91820 33633 180645 9620 60285 4010 56023 94690 146004 102928 49926 23089 134486 97000 40678 10809 114345 39548 177415 171878 83569 144510 120177 186520 75853 117575 26981 141133 76726 120283 188985 40366 154037 19475 20975 148997 185279 97766 123051 111805 1...
output:
18667660475
result:
ok "18667660475"
Test #52:
score: 0
Accepted
time: 35ms
memory: 38916kb
input:
175855 175855 70591 16211 113523 44578 120419 87423 97872 105646 173714 138493 98960 64837 21873 109702 135722 136711 127710 149295 45965 128234 50456 80698 13574 22642 65997 72147 34557 46621 45728 91073 75850 170603 55327 63155 22608 32783 128191 167894 82032 174349 2265 111925 118462 99725 77976 ...
output:
15462754295
result:
ok "15462754295"
Test #53:
score: 0
Accepted
time: 11ms
memory: 24108kb
input:
42547 42547 40736 6701 24768 42113 40413 39700 6520 38168 9664 15047 19902 2695 38903 41528 36416 14910 32757 14864 31024 21056 5181 501 5294 29329 28492 26787 22860 31487 41266 24246 41375 20890 26697 29613 34307 30605 18489 29389 9767 41681 33549 1280 24220 28711 39931 4134 41516 24130 30240 41066...
output:
905187425
result:
ok "905187425"
Test #54:
score: 0
Accepted
time: 137ms
memory: 66624kb
input:
200000 1000000000 999980802 999936590 999990392 999843887 948207689 999927195 999846995 999845734 999937879 999935244 593861984 999845593 999972462 999893566 999915249 999865900 999921295 999893313 207494625 999906227 487982645 999935394 999841929 907564184 154859264 999898133 999996901 999898882 99...
output:
185322430052141
result:
ok "185322430052141"
Test #55:
score: 0
Accepted
time: 136ms
memory: 66136kb
input:
200000 1000000000 999869150 999991082 999856642 999923937 120772840 999955385 876828834 999875256 999946582 311517520 999876537 615982489 999993688 999911756 555118245 999926666 999977172 999856121 999840808 999862392 856168722 999859124 489958929 999907376 999939135 999871452 999914869 999943004 99...
output:
186017114646437
result:
ok "186017114646437"
Test #56:
score: 0
Accepted
time: 132ms
memory: 66620kb
input:
200000 1000000000 999854139 999974863 999928652 999944767 999994791 112239074 999859977 999982223 205367879 727840872 497244825 999959598 650780750 999909227 999955438 999987933 999846870 999955829 999848482 999917864 499125294 999919176 999839384 21747120 950091975 999926762 999911020 366917064 999...
output:
186588250000541
result:
ok "186588250000541"
Test #57:
score: 0
Accepted
time: 131ms
memory: 66548kb
input:
200000 1000000000 999843655 999836365 999922286 999967366 999917587 999901728 999874570 999856605 999867616 999954577 999946616 999883094 999833553 999868715 999984650 999909989 795111597 999881732 999862153 999946165 999893296 999958666 999850397 999877801 999851609 999920330 999957357 999953738 99...
output:
187084571266516
result:
ok "187084571266516"
Test #58:
score: 0
Accepted
time: 125ms
memory: 66032kb
input:
200000 1000000000 999939482 999894813 999993661 999994501 999995534 999954855 67097034 999944218 999928534 9536085 999904652 999842629 999965643 999967037 999919667 999991933 140338372 999938573 999910062 999982258 819520290 999890039 999865664 999961190 999952013 999841862 455795379 999829175 99996...
output:
187526744622046
result:
ok "187526744622046"
Test #59:
score: 0
Accepted
time: 131ms
memory: 65848kb
input:
200000 1000000000 999865431 999892560 778641840 999909312 559239135 999861906 655296684 999846837 999899607 999974788 999923960 999883295 999931662 999909947 999903795 648691140 999877629 204751497 999948060 999990380 999896289 999998388 999835774 999970683 999915168 999926024 999837215 999950337 99...
output:
187926722757841
result:
ok "187926722757841"
Test #60:
score: 0
Accepted
time: 131ms
memory: 66372kb
input:
200000 1000000000 999984115 999889495 999969908 999976158 328759845 999897558 999833837 999982553 999836241 999966656 999850007 999933803 999868429 999944184 999921184 999897559 789309200 589446884 999964368 999864460 999908434 999957306 999951479 458446259 999841706 677145105 999849099 999956421 99...
output:
188292388778522
result:
ok "188292388778522"
Test #61:
score: 0
Accepted
time: 172ms
memory: 57832kb
input:
200000 1000000000 676414592 57348471 441821581 390056909 689996942 141801631 284253137 664302024 441341657 192231546 204034097 610697780 724530017 23620192 626289623 690051906 258718236 721490630 343336227 122185485 236722598 920610827 352314442 64637006 430538848 570590800 111382623 660202920 10421...
output:
100020510124168
result:
ok "100020510124168"
Test #62:
score: 0
Accepted
time: 176ms
memory: 54236kb
input:
200000 1000000000 562442478 280858750 29409077 317856339 959493020 765596753 389282063 489162118 591081706 228914162 759073096 969241066 553599171 456598591 796920503 288237241 918676142 138097295 655698796 569681040 579938954 628769181 598295243 865176925 774914957 439162119 12897325 10737765 94879...
output:
100020510117879
result:
ok "100020510117879"
Test #63:
score: 0
Accepted
time: 159ms
memory: 57700kb
input:
200000 1000000000 448135298 610922790 45255899 747140447 122370456 405348841 340986720 114517073 174270082 502814360 192776385 501779619 520190845 776834518 941526569 742271417 82243521 169001190 180683786 957683370 152184483 997980281 163667247 711732625 43036347 196475597 708438277 135682856 21609...
output:
100020510088060
result:
ok "100020510088060"
Test #64:
score: 0
Accepted
time: 164ms
memory: 57560kb
input:
200000 1000000000 428384270 605443824 765591756 325889781 512662397 4884011 950099923 64896955 688917165 799360093 174925000 312867404 639901975 460982729 880698802 355963722 752979344 483013344 349385074 663242257 682933295 277814333 796625545 473240327 982003475 4149137 937667371 312512387 2106078...
output:
100020510097558
result:
ok "100020510097558"
Test #65:
score: 0
Accepted
time: 171ms
memory: 58020kb
input:
200000 1000000000 333143287 960397881 360222925 858508247 261977539 919121039 624245074 824400019 57213467 465861809 444011153 300724838 752649430 189012174 846905537 615826719 167511449 801384613 543636213 274699970 610027921 842306434 957098460 144021117 284458067 334198105 473295248 571625618 829...
output:
100020510113715
result:
ok "100020510113715"
Test #66:
score: 0
Accepted
time: 281ms
memory: 69616kb
input:
195150 993357909 689239328 401977594 638836867 850263478 903332385 9655873 42069790 757136687 455488266 743116511 968808546 290164389 134848298 498972104 814868154 352983637 814696275 408995124 424060867 335985525 881029717 867738130 984665643 624580464 589054722 261716047 328754695 455707979 690251...
output:
97224823708661
result:
ok "97224823708661"
Test #67:
score: 0
Accepted
time: 270ms
memory: 69284kb
input:
191828 991054649 720838287 641902069 423066860 275786021 674912075 412232809 415351998 199939427 808181261 807392854 896323856 835557379 542191146 799661291 539790014 235479166 280976173 367128257 681218098 256289359 807668391 355806348 227877860 141933110 803463366 328194731 197775867 539140754 611...
output:
95276632630753
result:
ok "95276632630753"
Test #68:
score: 0
Accepted
time: 276ms
memory: 68056kb
input:
194408 994661584 240622443 175416085 246213717 9383590 901701097 370169230 555748596 344307434 812808450 385683171 595516483 746574259 646060629 682947504 901688014 175469851 608089142 187884855 194162675 171575691 149619761 612985521 860287770 944677042 800262986 499863176 146772422 428294861 53847...
output:
96861570360196
result:
ok "96861570360196"
Test #69:
score: 0
Accepted
time: 266ms
memory: 68976kb
input:
191987 995411899 375866257 107174790 431447230 652171975 585328066 17780987 694853041 144825102 854349408 22828905 352079151 334150539 939986906 540176291 270297902 973256288 365542847 969703590 170843070 316336389 836757063 784431298 264452605 356463976 799269157 18878859 434304159 419620124 696585...
output:
95779538473519
result:
ok "95779538473519"
Test #70:
score: 0
Accepted
time: 275ms
memory: 68440kb
input:
197101 991128210 172787134 222102192 293788270 547161848 626816948 404261559 852528765 291690301 961576279 471937183 378904853 897832638 445611323 326942476 746359031 94310643 280836100 329007574 828170419 352372060 363666396 694986251 457081058 924226661 213759047 253943761 756318267 198912562 2537...
output:
98032706642352
result:
ok "98032706642352"
Test #71:
score: 0
Accepted
time: 263ms
memory: 71020kb
input:
200000 1000000000 255863075 242465140 463372811 115649206 216951618 332293526 608132852 585085701 895325829 116894826 975125313 549853123 888264775 737254617 48488382 428552605 417087531 46080849 526996029 87737772 293068065 659823259 804224846 906394251 564708100 666363494 175971326 111877965 87137...
output:
100271392532437
result:
ok "100271392532437"
Test #72:
score: 0
Accepted
time: 275ms
memory: 70352kb
input:
200000 1000000000 870149723 693018525 89253291 427563450 340431548 635074354 212475153 941305935 749102300 70756202 171509950 724180413 612778972 305306468 487334651 843746851 299392328 407300366 599038782 246266619 962584060 297607554 479867517 496585088 700281590 628751088 744623625 408316045 1897...
output:
100214539556117
result:
ok "100214539556117"
Test #73:
score: 0
Accepted
time: 289ms
memory: 70816kb
input:
200000 1000000000 477638065 689150437 581484355 599276197 352989016 482964846 574016888 235101131 758133296 614650939 721056035 681884329 981076862 190008983 131005497 404738143 384879883 389485522 114674860 505104300 105685887 216031923 116219730 392753244 154776104 666549201 412602657 405441880 99...
output:
100190751557129
result:
ok "100190751557129"
Test #74:
score: 0
Accepted
time: 285ms
memory: 70924kb
input:
200000 1000000000 127179355 733055454 845588042 189724513 439122391 769377008 759514908 362452194 804179111 994794361 852163267 457300437 579694763 711337454 802729773 892610037 434746242 49012537 895875975 529270270 828077506 271860056 885608664 904505271 821748584 774527336 612447686 525542955 663...
output:
100369764579485
result:
ok "100369764579485"
Test #75:
score: 0
Accepted
time: 284ms
memory: 73152kb
input:
200000 1000000000 445879197 446511393 322718947 65973973 119535055 629004837 45759359 668024473 14968743 58023556 71267750 969245473 2450048 958948764 680533458 589026547 792585389 519021507 809517753 727453183 112235110 881805680 336858821 564245946 691299081 708339119 525603900 358788633 471303333...
output:
100347032241517
result:
ok "100347032241517"
Test #76:
score: 0
Accepted
time: 288ms
memory: 70120kb
input:
200000 1000000000 562473584 955612727 502051227 942182734 243487005 931687485 569030000 792525605 869018458 726309554 150782585 510926888 498549413 655127360 645832331 178051211 418932299 672105369 888484098 206675076 797185019 927975660 840148237 620871867 112396027 361186240 444100009 264821192 24...
output:
100210882827771
result:
ok "100210882827771"
Test #77:
score: 0
Accepted
time: 285ms
memory: 71040kb
input:
200000 1000000000 318718809 834887737 968367942 367025942 78957480 967458441 345083461 50977036 518360557 791112372 583400016 672202955 479222774 273111524 612480687 466406930 834101586 630850794 165159655 107699658 310013705 663549731 21649549 333226224 536875519 556378137 405702636 786028084 30902...
output:
100190066887747
result:
ok "100190066887747"
Test #78:
score: 0
Accepted
time: 289ms
memory: 67864kb
input:
200000 1000000000 556170948 196951634 165943606 765251019 33320309 757359137 66352005 639470995 691734366 532637837 350814638 780645114 743573336 121588244 80763939 870770888 403493202 302769259 786251359 730544054 299793444 584711240 293388237 907587484 860041802 845508193 886296697 365685649 84134...
output:
100233572445077
result:
ok "100233572445077"
Test #79:
score: 0
Accepted
time: 282ms
memory: 70496kb
input:
200000 1000000000 735375252 158986068 964169949 557465818 48221132 234023833 818202137 431612553 499836381 57177200 315663846 520054402 434853128 275891125 464796769 578555737 984667448 942907682 865026741 905210692 636813631 683977112 855074070 354823716 904901463 915361568 441890652 670612953 2817...
output:
100418768706998
result:
ok "100418768706998"
Test #80:
score: 0
Accepted
time: 269ms
memory: 70704kb
input:
200000 1000000000 56296976 556270579 675286598 833131976 330405703 973613148 978652411 775409832 575774303 112697447 724522072 311759820 720698312 159396036 819599128 238321875 253594614 769533679 437116756 88133687 831856019 896865433 345347638 28646422 584961261 400915237 994130392 826157198 17547...
output:
100396865384920
result:
ok "100396865384920"
Test #81:
score: 0
Accepted
time: 276ms
memory: 69020kb
input:
200000 1000000000 861475116 879645326 83069106 477362246 135812661 716944036 144098688 575702913 326428528 281473581 32025570 214947979 502600960 53496812 946987657 577713439 574058881 614717554 680239057 502343488 118248025 341694561 674509472 673271890 251766484 652603948 138612035 120390299 21098...
output:
100172301827698
result:
ok "100172301827698"
Test #82:
score: 0
Accepted
time: 276ms
memory: 69060kb
input:
200000 1000000000 633319783 883075487 589773733 360765023 330885877 950995278 344384335 989856199 722279706 395485816 188802054 735683695 114014203 985001541 881218566 586050195 288080584 123987457 36088545 396001346 433652458 967743429 610772478 799536378 196099333 87771422 120425686 259666052 2067...
output:
100334724362329
result:
ok "100334724362329"
Test #83:
score: 0
Accepted
time: 281ms
memory: 69056kb
input:
200000 1000000000 226618101 316857969 728903727 145284367 23742982 533094746 551964200 719179664 918094035 846099589 850409526 766857975 131993526 181366510 647063550 613481983 452144861 232130682 94036478 730648908 455928442 317485472 79800047 212941518 258999865 128601730 654919786 827705273 10872...
output:
100345868044738
result:
ok "100345868044738"
Test #84:
score: 0
Accepted
time: 288ms
memory: 73016kb
input:
200000 1000000000 358528453 834890483 341062782 30602758 810977060 590653995 614700013 249401029 731170819 227712747 834725825 105010455 468042434 352063849 137650709 715188797 104220070 728552780 395072877 363053785 401673318 931537243 131335357 683782888 665383848 269904198 618788032 938386379 527...
output:
100311143662819
result:
ok "100311143662819"
Test #85:
score: 0
Accepted
time: 276ms
memory: 70548kb
input:
200000 1000000000 416812602 800347140 329556285 745389804 586929719 516168963 966352824 785082672 326493195 203363078 935172578 295914024 712193035 560159511 219571487 314129751 329618359 335319735 960971224 529283136 399387953 343007677 619658013 564966531 32998770 67467851 628807798 753250277 2137...
output:
100358110778486
result:
ok "100358110778486"
Extra Test:
score: 0
Extra Test Passed