QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#423994#2070. Heavy StonesEstelle_NAC ✓110ms29444kbC++145.6kb2024-05-28 20:35:462024-05-28 20:35:47

Judging History

你现在查看的是最新测评结果

  • [2024-05-28 20:35:47]
  • 评测
  • 测评结果:AC
  • 用时:110ms
  • 内存:29444kb
  • [2024-05-28 20:35:46]
  • 提交

answer

#include <cmath>
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

const int N = 200005;

long long n, cnt, tot, a[N], s[N];
long long answer, b[N], c[N];

int rt, x, y, z, topL, topR, bin[N], stL[N], stR[N];

double kL[N], kR[N];
vector <int> pop[N];

struct Node
{
    int l, r, dat, num, siz;
    long long val, sum, o;
    double k;
};
Node t[N << 1];

long long New(int num, long long val, long long o, double k)
{
    long long pos;
    if(cnt)
        pos = bin[cnt --];
    else
        pos = ++tot;
    t[pos] = {0, 0, rand(), num, num, val, val, o, k};
    return pos;
}

void push_up(long long p)
{
    t[p].siz = t[t[p].l].siz + t[t[p].r].siz + t[p].num;
    t[p].sum = t[t[p].l].sum + t[t[p].r].sum + t[p].val;
}

long long merge(long long x, long long y)
{
    if(!x || !y)
        return x + y;
    if(t[x].dat > t[y].dat)
    {
        t[x].r = merge(t[x].r, y);
        push_up(x);
        return x;
    }
    else
    {
        t[y].l = merge(x, t[y].l);
        push_up(y);
        return y;
    }
}

void split(long long p, int &x, int &y, double k, bool o = 0)
{
    if(!p)
    {
        x = y = 0;
        return;
    }
    if((!o && t[p].k > k) || (o && t[p].k >= k))
    {
        y = p;
        split(t[p].l, x, t[p].l, k, o);
    }
    else
    {
        x = p;
        split(t[p].r, t[p].r, y, k, o);
    }
    push_up(p);
}

double get(long long x, long long y)
{
    return 1.0 * (s[x] - s[y]) / (x - y);
}

long long ins(double k, long long p)
{
    split(rt, x, y, k);
    long long s = t[y].siz;
    answer += t[x].sum * t[p].siz;
    rt = merge(x, merge(p, y));
    return s;
}

long long del(double k, long long o)
{
    long long s;
    split(rt, x, y, k);
    split(x, x, z, k, 1);
    if(!t[z].l && !t[z].r)
    {
        bin[++cnt] = z;
        answer -= t[x].sum * t[z].siz;
        s = t[y].siz;
        rt = merge(x, y);
    }
    else
    {
        long long u = z, v = (t[z].l ? t[z].l : t[z].r);
        if(t[u].o == o)
        {
            bin[++cnt] = u;
            if(t[z].l)
            {
                answer -= (t[x].sum + t[v].sum) * t[u].num;
                s = t[y].siz;
            }
            else
            {
                answer -= t[x].sum * t[u].num;
                s = t[y].siz + t[v].siz;
            }
            rt = merge(x, merge(v, y));
        }
        else
        {
            bin[++cnt] = v;
            t[u].l = t[u].r = 0;
            t[u].siz = t[u].num;
            t[u].sum = t[u].val;
            if(t[z].l)
            {
                answer -= t[x].sum * t[v].num;
                s = t[y].siz + t[u].siz;
            }
            else
            {
                answer -= (t[x].sum + t[u].sum) * t[v].num;
                s = t[y].siz;
            }
            rt = merge(x, merge(u, y));
        }
    }
    return s;
}

signed main()
{
    scanf("%lld", &n);
    for(long long i = 1; i <= n; ++ i)
    {
        scanf("%lld", &a[i]);
        s[i] = s[i - 1] + a[i];
        b[i] = b[i - 1] + a[i] * i;
        c[i] = c[i - 1] + a[i] * (n - i + 1);
    }

    for(long long i = n; i >= 1; -- i)
    {
        stR[++topR] = i;
        while(topR > 2 && get(stR[topR], stR[topR - 2]) <= get(stR[topR], stR[topR - 1]))
            pop[i].push_back(stR[topR - 1]), stR[topR - 1] = stR[topR], -- topR;
    }

    for(long long i = 2; i <= topR; ++ i)
    {
        long long l = stR[i], r = stR[i - 1];
        kR[r] = abs(get(l, r));
        long long pos = ins(kR[r], New(r - l, s[r] - s[l], 1, kR[r]));
        answer += (c[r] - c[l]) + (s[r] - s[l]) * (pos + 1 - (n - r + 1));
    }

    printf("%lld ", answer + a[1] * n - a[1]);

    stL[++topL] = 1;
    for(long long i = 2, pos, l, r; i <= n; ++ i)
    {
        stL[++topL] = i;
        while(topL > 2 && 1.0 * (s[i] - s[stL[topL - 2] - 1] - a[i]) / (stL[topL - 2] - i) >= 1.0 * (s[i] - s[stL[topL - 1] - 1] - a[i]) / (stL[topL - 1] - i))
        {
            l = stL[topL - 2];
            r = stL[topL - 1];
            pos = del(kL[stL[topL - 2]], 0);
            answer -= (b[r - 1] - b[l - 1]) + (s[r - 1] - s[l - 1]) * (pos + 1 - l); 
            stL[-- topL] = i;
        }
        kL[stL[topL - 1]] = abs(1.0 * (s[i] - s[stL[topL - 1] - 1] - a[i]) / (stL[topL - 1] - i));
        pos = ins(kL[stL[topL - 1]], New(i - stL[topL - 1], s[i - 1] - s[stL[topL - 1] - 1], 0, kL[stL[topL - 1]]));
        answer += (b[i - 1] - b[stL[topL - 1] - 1]) + (s[i - 1] - s[stL[topL - 1] - 1]) * (pos + 1 - stL[topL - 1]);

        long long u = stR[topR --];
        if(!topR)
            continue;

        pos = del(kR[stR[topR]], 1);
        answer -= (c[stR[topR]] - c[u]) + (s[stR[topR]] - s[u]) * (pos + 1 - (n - stR[topR] + 1));
        
        if(!pop[u].size() && stR[topR] != i)
        {
            r = stR[topR];
            kR[r] = abs(get(r, i));
            pos = ins(kR[r], New(r - i, s[r] - s[i], 1, kR[r]));
            answer += (c[r] - c[i]) + (s[r] - s[i]) * (pos + 1 - (n - r + 1));
            stR[++topR] = i;
        }
        for(long long j = (long long)pop[u].size() - 1; j >= 0; -- j)
        {
            l = pop[u][j]; 
            r = stR[topR];
            kR[r] = abs(get(l, r));
            pos = ins(kR[r], New(r - l, s[r] - s[l], 1, kR[r]));
            answer += (c[r] - c[l]) + (s[r] - s[l]) * (pos + 1 - (n - r + 1));
            stR[++topR] = pop[u][j];
        }

        printf("%lld ", answer + a[i] * n - a[i]);
    }

    return 0;
}
/*
10
18 37 81 6 58 99 87 34 75 
*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 16196kb

input:

5
2 1 3 5 4

output:

35 35 36 43 49 

result:

ok single line: '35 35 36 43 49 '

Test #2:

score: 0
Accepted
time: 0ms
memory: 16112kb

input:

10
18 37 81 6 58 99 87 34 75 9

output:

2637 2637 2657 2657 2695 2949 2995 2905 2880 2880 

result:

ok single line: '2637 2637 2657 2657 2695 2949 2995 2905 2880 2880 '

Test #3:

score: 0
Accepted
time: 83ms
memory: 24640kb

input:

200000
479735 430060 863649 878892 889364 241972 927862 32858 714406 674598 88114 438434 167733 457299 951288 510096 635193 504974 649221 617914 223711 812277 364169 746142 836563 825312 994240 198961 567906 905208 509572 744710 891294 928176 833980 985385 858440 50835 86130 324862 796245 935992 383...

output:

9992833979971052 9992833979971052 9992833980354966 9992779245594768 9992703452732543 9992625566170070 9992625565960956 9992591568400874 9992591568400874 9992591568189384 9992591567396390 9992591567396390 9992591567476009 9992591567864059 9992591571455644 9992591572452874 9992591574009688 99925915745...

result:

ok single line: '9992833979971052 9992833979971...203005830427 10004203006781811 '

Test #4:

score: 0
Accepted
time: 87ms
memory: 24600kb

input:

200000
754184 13065 865956 768626 744822 919059 583237 600724 524170 165425 246285 226816 966566 610515 550388 715978 549675 83917 323652 423422 266395 285394 470160 472551 743112 879255 493014 992502 158286 301973 857254 395231 282559 806597 243952 205846 976027 598783 69632 165916 622634 620757 34...

output:

10014997841701475 10014947015238274 10014947015238274 10014947015993835 10014917512559448 10014868558588544 10014784759644306 10014768120716895 10014747984710856 10014743158715252 10014743158715252 10014743158776643 10014743160298065 10014743161445632 10014743159820460 10014743158450587 100147431338...

result:

ok single line: '10014997841701475 100149470152...7021303093862 9987021303093862 '

Test #5:

score: 0
Accepted
time: 85ms
memory: 24596kb

input:

200000
783905 465734 702646 342070 382378 612468 565748 741917 648664 523500 182013 89445 129572 26912 175340 537820 717500 718402 563606 124584 111640 830294 957543 449869 563613 901195 496363 918492 226878 429682 770972 654243 222706 539682 471463 654386 31958 381760 352938 783523 851106 354268 75...

output:

9985525267421517 9985468293020605 9985468291830972 9985434229308153 9985434229308153 9985434229224741 9985434226842360 9985434224335794 9985404337013738 9985374417560553 9985369520866620 9985369520652405 9985369520589872 9985369520589872 9985369520721535 9985369522444873 9985369525429091 99853695285...

result:

ok single line: '9985525267421517 9985468293020...5790145914810 9975830720773589 '

Test #6:

score: 0
Accepted
time: 93ms
memory: 24644kb

input:

200000
853686 20716 174697 869738 857025 507882 375300 849975 893238 468077 184722 535631 383301 657603 49942 235054 316530 521594 464021 979922 188332 335907 114903 261684 434608 966750 619976 793830 275183 498775 690216 769588 589049 958997 995520 845297 350658 198715 707600 18882 203867 132974 16...

output:

10007482900924066 10007412205735064 10007412205735064 10007412206584086 10007412208102723 10007412205041250 10007412203774418 10007412203774418 10007381409966150 10007302822767145 10007302821693099 10007302821693099 10007302821528524 10007302820980147 10007302819330353 10007302819330353 100073028195...

result:

ok single line: '10007482900924066 100074122057...782048899392 10000853953946590 '

Test #7:

score: 0
Accepted
time: 89ms
memory: 24704kb

input:

200000
282721 513944 210659 728001 402993 628298 260323 376301 404417 439890 298253 575700 991264 735782 387209 874869 995018 778731 247456 286146 598879 216939 91609 177310 82415 36330 265803 953105 564707 201163 357501 390048 142474 266916 46616 539260 570794 792662 270237 67158 511870 166602 9035...

output:

10008509175990736 10008509175918674 10008509175918674 10008509176578011 10008509171139661 10008509170903880 10008509157826476 10008509157826476 10008509157970570 10008509158067444 10008509158067444 10008509158889313 10008509162066449 10008509131249736 10008509108213966 10008509107556161 100084882028...

result:

ok single line: '10008509175990736 100085091759...908130262195 10006908130262195 '

Test #8:

score: 0
Accepted
time: 90ms
memory: 29184kb

input:

200000
22 25 28 34 59 61 68 80 108 116 119 121 121 123 131 131 141 143 152 166 167 174 184 215 228 231 264 279 307 309 313 314 327 339 341 362 381 399 414 421 430 449 477 486 490 500 502 508 529 529 562 566 569 571 585 597 641 650 658 675 680 684 698 721 723 724 731 732 737 755 784 785 810 813 817 8...

output:

10003490282328154 10003490282328154 10003490282328160 10003490282328181 10003490282328283 10003490282328418 10003490282328590 10003490282328841 10003490282329300 10003490282329851 10003490282330437 10003490282331046 10003490282331657 10003490282332292 10003490282333033 10003490282333782 100034902823...

result:

ok single line: '10003490282328154 100034902823...436775206431 10023436775206431 '

Test #9:

score: 0
Accepted
time: 85ms
memory: 27196kb

input:

200000
38 11 44 65 78 56 92 134 177 153 183 211 163 119 196 219 225 251 246 221 279 286 262 297 287 223 312 209 333 354 332 350 310 368 317 419 405 426 426 433 399 446 454 452 460 435 489 376 508 475 510 463 493 518 544 524 520 568 580 572 564 580 541 595 469 607 644 652 606 681 669 632 700 682 709 ...

output:

9998421200211521 9998421200211521 9998421200211527 9998421200211608 9998421200211749 9998421200211815 9998421200212039 9998421200212551 9998421200213406 9998421200214112 9998421200215064 9998421200216326 9998421200217088 9998421200217274 9998421200218417 9998421200219959 9998421200221614 99984212002...

result:

ok single line: '9998421200211521 9998421200211...237707981667 10024237707982278 '

Test #10:

score: 0
Accepted
time: 81ms
memory: 28884kb

input:

200000
27 7 48 45 53 47 79 72 25 93 99 140 55 141 75 129 147 205 239 210 259 194 272 277 213 350 369 102 210 35 410 376 387 277 109 341 488 480 515 428 536 536 496 551 70 498 569 611 598 563 299 590 630 425 620 659 562 659 614 682 679 648 522 680 667 795 675 764 709 819 808 597 698 651 828 845 859 7...

output:

9993178236777521 9993178236777521 9993178236777542 9993178236777598 9993178236777675 9993178236777736 9993178236777951 9993178236778025 9993178236778025 9993178236778391 9993178236778879 9993178236779783 9993178236779793 9993178236780750 9993178236780935 9993178236781810 9993178236783009 99931782367...

result:

ok single line: '9993178236777521 9993178236777...093542881356 10005093542881356 '

Test #11:

score: 0
Accepted
time: 86ms
memory: 28408kb

input:

200000
120 1 84 154 174 242 57 115 145 258 58 113 251 296 21 120 47 322 326 312 63 257 338 376 257 15 309 453 45 388 350 361 385 309 547 265 565 477 518 508 651 583 330 467 668 440 651 262 629 597 699 705 510 661 735 709 680 781 783 404 731 722 848 699 829 716 735 516 665 865 914 896 549 916 745 666...

output:

10002949533110704 10002949533110668 10002949533110668 10002949533110855 10002949533111172 10002949533111528 10002949533111448 10002949533111448 10002949533111631 10002949533112081 10002949533111958 10002949533111958 10002949533112751 10002949533112470 10002949533112045 10002949533112045 100029495331...

result:

ok single line: '10002949533110704 100029495331...416301216916 10013416301217739 '

Test #12:

score: 0
Accepted
time: 83ms
memory: 26756kb

input:

200000
129 17 184 106 177 58 137 110 159 154 269 97 49 332 268 220 216 376 90 310 384 378 163 360 385 390 229 48 306 241 389 386 439 424 321 335 455 432 64 350 411 554 522 534 371 564 575 602 619 419 630 23 306 661 531 688 620 511 508 757 681 670 744 758 782 794 810 604 498 385 676 848 771 443 632 1...

output:

9977051105348378 9977051105348376 9977051105348376 9977051105348465 9977051105348485 9977051105348485 9977051105348505 9977051105348557 9977051105348862 9977051105349176 9977051105349518 9977051105349298 9977051105349298 9977051105351685 9977051105353523 9977051105354625 9977051105355619 99770511053...

result:

ok single line: '9977051105348378 9977051105348...9366081802836 9989366081837380 '

Test #13:

score: 0
Accepted
time: 82ms
memory: 28360kb

input:

200000
179 212 181 155 263 276 42 280 47 307 305 102 7 390 27 127 297 358 43 193 340 122 220 39 517 273 200 19 474 453 419 145 483 403 493 539 495 525 598 576 629 662 683 239 552 258 662 706 46 659 402 729 610 374 537 765 64 719 788 707 597 818 401 713 783 842 629 768 841 842 923 621 754 883 930 510...

output:

9989681479672757 9989681479672735 9989681479672332 9989681479672332 9989681479672332 9989681479671542 9989681479670194 9989681479670194 9989681479670199 9989681479670353 9989681479670121 9989681479669600 9989681479669600 9989681479669813 9989681479669715 9989681479669715 9989681479670589 99896814796...

result:

ok single line: '9989681479672757 9989681479672...6641482442654 9976641482442679 '

Test #14:

score: 0
Accepted
time: 87ms
memory: 26388kb

input:

200000
221 86 43 23 16 104 32 35 275 227 307 64 264 236 18 357 112 459 169 7 354 125 429 41 402 526 505 526 462 535 492 55 592 272 172 622 429 509 539 277 678 76 734 371 365 523 739 500 304 819 314 143 510 825 714 743 805 669 760 751 877 899 919 117 948 1014 638 910 777 1033 846 1034 910 297 989 105...

output:

9969234033814217 9969234033812987 9969234033812767 9969234033812740 9969234033812740 9969234033812863 9969234033812850 9969234033812850 9969234033814196 9969234033815446 9969234033817023 9969234033817023 9969234033818515 9969234033818639 9969234033818639 9969234033821312 9969234033821406 99692340338...

result:

ok single line: '9969234033814217 9969234033812...3878090447102 9983878090447231 '

Test #15:

score: 0
Accepted
time: 92ms
memory: 28508kb

input:

200000
210 253 2 266 149 18 14 369 22 100 244 364 40 108 92 82 239 56 382 304 418 182 498 6 1 435 540 468 165 351 393 546 555 476 248 22 594 591 746 397 782 268 65 641 792 468 885 709 50 898 387 4 733 313 627 538 1012 936 765 1007 1022 580 968 1073 1089 644 799 1051 396 677 944 892 1093 326 1159 114...

output:

9980743000304902 9980743000303707 9980743000302075 9980743000302075 9980743000301750 9980743000301615 9980743000301615 9980743000302188 9980743000302099 9980743000302099 9980743000302940 9980743000303101 9980743000302145 9980743000302145 9980743000302197 9980743000302213 9980743000302592 99807430003...

result:

ok single line: '9980743000304902 9980743000303...970631563236 10003970631563279 '

Test #16:

score: 0
Accepted
time: 88ms
memory: 26416kb

input:

200000
224 287 21 42 45 283 89 95 408 113 124 133 133 136 140 182 445 183 110 310 203 46 488 480 446 39 398 496 305 483 470 466 516 594 281 426 201 185 363 348 275 442 602 683 720 666 747 699 413 464 473 574 548 776 299 428 673 792 210 753 738 609 607 862 805 557 686 314 818 725 223 446 498 940 212 ...

output:

10000761695648274 10000761695647035 10000761695644802 10000761695644802 10000761695644826 10000761695645329 10000761695645477 10000761695645477 10000761695647037 10000761695646887 10000761695646887 10000761695646907 10000761695646936 10000761695646974 10000761695647031 10000761695647593 100007616956...

result:

ok single line: '10000761695648274 100007616956...541099556023 10015541099564586 '

Test #17:

score: 0
Accepted
time: 85ms
memory: 26488kb

input:

200000
316 131 337 347 22 375 396 378 37 454 86 433 436 104 499 11 128 230 11 551 286 544 271 381 228 493 294 201 337 594 667 608 714 264 148 556 454 594 444 34 235 470 780 89 82 446 474 562 795 409 218 53 888 665 32 919 975 732 875 855 236 985 811 996 859 281 150 874 692 744 879 780 941 10 835 1083...

output:

10003821471786399 10003821471785311 10003821471785311 10003821471785103 10003821471784427 10003821471784427 10003821471784801 10003821471783724 10003821471782336 10003821471782336 10003821471782161 10003821471782161 10003821471781363 10003821471780062 10003821471779969 10003821471778898 100038214717...

result:

ok single line: '10003821471786399 100038214717...979558507405 10010979558517495 '

Test #18:

score: 0
Accepted
time: 99ms
memory: 27852kb

input:

200000
24 7 13 41 51 48 52 46 57 76 20 86 86 71 91 101 111 115 121 100 52 16 129 130 153 129 158 154 167 174 114 180 195 208 217 221 228 236 240 176 279 214 295 291 304 296 299 317 321 130 319 325 278 348 376 377 385 306 359 336 422 427 379 391 419 434 455 474 484 443 495 473 506 499 526 534 536 535...

output:

7505967755427056 7505967755427045 7505967755427045 7505967755427096 7505967755427205 7505967755427312 7505967755427436 7505967755427528 7505967755427691 7505967755427858 7505967755427858 7505967755428303 7505967755428814 7505967755429145 7505967755429721 7505967755430457 7505967755431353 75059677554...

result:

ok single line: '7505967755427056 7505967755427...718035300637 12534718035300637 '

Test #19:

score: 0
Accepted
time: 87ms
memory: 28604kb

input:

200000
58 95 94 66 147 147 10 150 163 157 155 49 116 225 45 279 281 237 301 236 322 265 295 138 333 350 247 323 363 381 395 337 433 349 259 460 438 523 611 621 340 627 633 662 127 674 112 709 554 554 742 472 647 734 680 835 809 720 825 871 828 885 841 912 693 790 895 625 1012 930 841 948 1012 1049 9...

output:

11104327394980383 11104327394980383 11104327394980398 11104327394980398 11104327394980569 11104327394980457 11104327394980457 11104327394980750 11104327394981274 11104327394981739 11104327394981631 11104327394981631 11104327394981665 11104327394982252 11104327394982252 11104327394984526 111043273949...

result:

ok single line: '11104327394980383 111043273949...1588249094580 8901588249097377 '

Test #20:

score: 0
Accepted
time: 80ms
memory: 26960kb

input:

200000
109 163 5 109 171 190 57 145 16 236 98 41 251 3 272 170 153 334 457 158 337 367 492 242 131 529 432 478 606 573 24 280 191 606 604 473 387 627 619 303 707 691 637 670 768 673 503 770 444 734 863 755 695 843 940 772 916 767 840 596 1032 1034 934 1079 475 1072 895 987 950 1003 978 988 1131 1104...

output:

10609712362384669 10609712362384565 10609712362384207 10609712362384207 10609712362384373 10609712362384438 10609712362384219 10609712362384178 10609712362384178 10609712362384397 10609712362384309 10609712362384309 10609712362384503 10609712362384503 10609712362386448 10609712362387234 106097123623...

result:

ok single line: '10609712362384669 106097123623...4652208537636 9404652208537636 '

Test #21:

score: 0
Accepted
time: 108ms
memory: 27876kb

input:

200000
77 90 24 97 10 13 100 68 8 62 21 93 103 58 146 121 102 155 144 64 41 72 158 100 179 164 5 174 180 151 50 189 148 181 217 180 144 71 222 130 226 216 243 170 244 211 260 289 125 267 33 296 180 222 188 286 178 342 338 346 291 179 292 349 341 290 347 1 286 358 266 377 379 317 351 368 442 396 229 ...

output:

7578294190670325 7578294190670035 7578294190669694 7578294190669669 7578294190669498 7578294190669498 7578294190669588 7578294190669602 7578294190669552 7578294190669552 7578294190669565 7578294190669934 7578294190670453 7578294190670542 7578294190671674 7578294190672544 7578294190673104 75782941906...

result:

ok single line: '7578294190670325 7578294190670...266542211920 12456266542231137 '

Test #22:

score: 0
Accepted
time: 101ms
memory: 29444kb

input:

200000
580 274 720 437 768 146 903 746 873 587 409 412 23 637 1060 912 456 115 755 139 1097 1255 1223 1468 1080 117 1432 1057 1212 1410 681 1602 443 1728 1272 1814 106 1416 1777 1807 1899 1944 31 1616 388 1873 1496 2128 2055 1473 1287 2309 339 2373 1885 2305 1777 2507 2009 2104 1966 1927 2244 816 27...

output:

12342777089034706 12342777089034350 12342777089034350 12342777089034353 12342777089034062 12342777089034062 12342777089034481 12342777089034444 12342777089032891 12342777089029653 12342777089028879 12342777089028493 12342777089028493 12342777089028946 12342777089031282 12342777089030610 123427770890...

result:

ok single line: '12342777089034706 123427770890...2822560263986 7612822560263986 '

Test #23:

score: 0
Accepted
time: 84ms
memory: 26600kb

input:

200000
228 100 128 54 72 281 252 187 11 265 118 290 34 374 294 397 343 361 280 298 402 175 417 86 60 413 457 389 134 353 233 96 156 466 400 71 504 529 488 383 538 293 132 543 577 332 405 401 118 554 353 662 430 129 470 681 668 668 477 574 601 628 462 684 748 603 414 735 462 777 521 741 356 791 123 4...

output:

9319857724602876 9319857724602060 9319857724601986 9319857724601930 9319857724601930 9319857724602491 9319857724602865 9319857724602624 9319857724602624 9319857724603157 9319857724603264 9319857724603396 9319857724603396 9319857724605898 9319857724607700 9319857724610864 9319857724613321 93198577246...

result:

ok single line: '9319857724602876 9319857724602...219442482832 10673219442482863 '

Test #24:

score: 0
Accepted
time: 110ms
memory: 27680kb

input:

200000
1910 58 132 209 1688 1019 2345 683 2156 2439 796 1185 1013 2394 683 2845 3321 3158 3222 3351 1452 3067 2846 247 3353 4373 1587 3679 4461 4279 2342 1077 2933 2643 3304 2339 5577 5038 786 4214 4163 5284 6383 5633 6512 1209 2813 5882 5260 2371 6937 6059 614 1479 6548 7973 8071 5859 7070 8303 402...

output:

12955690469121616 12955690469113528 12955690469113528 12955690469113679 12955690469116865 12955690469119523 12955690469126816 12955690469127125 12955690469134610 12955690469143627 12955690469141951 12955690469141951 12955690469142168 12955690469150265 12955690469150265 12955690469172068 129556904692...

result:

ok single line: '12955690469121616 129556904691...6737249914622 7056737249914625 '

Test #25:

score: 0
Accepted
time: 95ms
memory: 27620kb

input:

200000
1929 1111 2158 1542 1810 2764 439 3685 3232 3682 902 1477 2705 1131 653 1238 1509 1512 311 3692 3920 728 4686 3114 4244 4202 378 4873 3563 5233 1519 2629 2469 5229 1095 892 5295 5139 5769 5273 5852 4359 5273 5944 866 4259 3810 3736 3807 2214 4460 2808 5858 6920 2826 6063 6226 6551 5434 4772 2...

output:

12912884164246921 12912884164244878 12912884164244878 12912884164245309 12912884164245528 12912884164244276 12912884164241841 12912884164241841 12912884164233634 12912884164215984 12912884164197064 12912884164197064 12912884164197301 12912884164188999 12912884164188999 12912884164189045 129128841641...

result:

ok single line: '12912884164246921 129128841642...2406424903944 7092406424903944 '

Test #26:

score: 0
Accepted
time: 82ms
memory: 26444kb

input:

200000
269 327 10 27 29 29 232 295 36 38 379 422 392 127 156 434 177 432 436 440 198 375 495 429 453 441 231 444 343 386 311 618 223 444 637 497 406 648 641 85 188 687 90 694 479 278 564 694 163 330 499 775 185 421 836 696 504 429 853 887 795 887 672 358 518 10 874 849 846 622 1017 60 796 408 769 46...

output:

9872265226260704 9872265226259248 9872265226257617 9872265226257617 9872265226257636 9872265226257657 9872265226258287 9872265226259088 9872265226258831 9872265226258831 9872265226260826 9872265226263506 9872265226265732 9872265226265559 9872265226265559 9872265226268781 9872265226268910 98722652262...

result:

ok single line: '9872265226260704 9872265226259...802308376411 10133802308376471 '

Test #27:

score: 0
Accepted
time: 95ms
memory: 26200kb

input:

200000
218 2 288 16 195 27 292 34 45 226 164 216 333 74 193 346 146 306 124 139 312 368 266 141 21 226 409 414 150 99 162 174 150 74 392 471 449 141 28 325 146 339 545 499 547 133 340 166 365 347 9 375 239 525 603 500 589 465 183 419 603 155 631 494 548 54 474 555 652 69 449 89 376 546 589 251 749 4...

output:

7631857109426968 7631857109426122 7631857109426122 7631857109425872 7631857109425872 7631857109425883 7631857109425992 7631857109425770 7631857109425770 7631857109426498 7631857109426911 7631857109427730 7631857109429080 7631857109429080 7631857109429558 7631857109432058 7631857109432083 76318571094...

result:

ok single line: '7631857109426968 7631857109426...702861835367 12357702862068468 '

Test #28:

score: 0
Accepted
time: 0ms
memory: 16256kb

input:

1
1000000

output:

0 

result:

ok single line: '0 '