QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#71822#3563. Treatment ProjectHe_Ren100 ✓535ms119188kbC++232.4kb2023-01-12 01:24:582023-01-12 01:25:03

Judging History

This is the latest submission verdict.

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-01-12 01:25:03]
  • Judged
  • Verdict: 100
  • Time: 535ms
  • Memory: 119188kb
  • [2023-01-12 01:24:58]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int MAXN = 1e5 + 5;
const int MAXP = MAXN * 20;
const ll linf = 0x3f3f3f3f3f3f3f3f;

int pcnt;
array<int, 4> p[MAXN];
vector<pii> g[MAXP];

int dsc[MAXN], dcnt = 0;

int pt[MAXN];
#define lowbit(x) ((x)&-(x))
void insert(int x, int u) {
    x = upper_bound(dsc + 1, dsc + dcnt + 1, x) - dsc - 1;

    while (x <= dcnt) {
        if (pt[x]) {
            g[++pcnt] = {{pt[x], 0}, {u, 0}};
            pt[x] = pcnt;
        } else
            pt[x] = u;

        x += lowbit(x);
    }
}
void query(int x, int u) {
    x = upper_bound(dsc + 1, dsc + dcnt + 1, x) - dsc - 1;

    while (x) {
        if (pt[x])
            g[u].emplace_back(pt[x], 0);

        x ^= lowbit(x);
    }
}

int main(void) {
    int d, n;
    scanf("%d%d", &d, &n);

    for (int i = 1; i <= n; ++i)
        scanf("%d%d%d%d", &p[i][0], &p[i][1], &p[i][2], &p[i][3]);

    int S = 2 * n + 1, T = 2 * n + 2;
    pcnt = T;
    vector< array<int, 4>> vec;

    for (int i = 1; i <= n; ++i) {
        g[i].emplace_back(i + n, p[i][3]);

        if (p[i][1] == 1)
            g[S].emplace_back(i, 0);

        if (p[i][2] == d)
            g[i + n].emplace_back(T, 0);

        vec.push_back({p[i][2] + 1 - p[i][0], 1, p[i][2] + 1 + p[i][0], i + n});
        vec.push_back({p[i][1] - p[i][0], 0, p[i][1] + p[i][0], i});

        dsc[++dcnt] = p[i][1] + p[i][0];
    }

    sort(dsc + 1, dsc + dcnt + 1);
    dcnt = unique(dsc + 1, dsc + dcnt + 1) - dsc - 1;

    sort(vec.begin(), vec.end());

    for (auto t : vec) {
        if (t[1] == 0)
            insert(t[2], t[3]);
        else
            query(t[2], t[3]);
    }

    static ll dis[MAXP];
    static bool vis[MAXP];
    priority_queue< pair<ll, int>> q;
    memset(dis, 0x3f, sizeof(dis));
    dis[S] = 0;
    q.emplace(0, S);

    while (q.size()) {
        int u = q.top().second;
        q.pop();

        if (vis[u])
            continue;

        vis[u] = 1;

        for (auto it : g[u]) {
            int v = it.first;
            ll nxt = dis[u] + it.second;

            if (nxt < dis[v])
                dis[v] = nxt, q.emplace(-dis[v], v);
        }
    }

    if (dis[T] == linf)
        printf("-1");
    else
        printf("%lld", dis[T]);

    return 0;
}

详细

Subtask #1:

score: 4
Accepted

Test #1:

score: 4
Accepted
time: 236ms
memory: 109836kb

input:

1000000000 100000
1 811370001 811380000 1000000000
1 413190001 413200000 1000000000
1 462480001 462490000 1000000000
1 384860001 384870000 1000000000
1 543220001 543230000 1000000000
1 766300001 766310000 1000000000
1 348890001 348900000 1000000000
1 996350001 996360000 1000000000
1 302700001 302710...

output:

100000000000000

result:

ok single line: '100000000000000'

Test #2:

score: 0
Accepted
time: 179ms
memory: 110288kb

input:

1000000000 100000
1 949530001 949540000 1000000000
1 739970001 739980000 1000000000
1 199740001 199750000 1000000000
1 481170001 481180000 1000000000
1 691390001 691400000 1000000000
1 694040001 694050000 1000000000
1 229990001 230000000 1000000000
1 306470001 306480000 1000000000
1 293790001 293800...

output:

-1

result:

ok single line: '-1'

Test #3:

score: 0
Accepted
time: 334ms
memory: 119052kb

input:

1000000000 100000
1 999950001 999976550 1550
1 22208 50000 2793
1 18436 50000 6565
1 999999902 1000000000 99
1 1 1959 1959
1 999987171 1000000000 12830
1 13195 50000 11806
1 999950001 999987417 12417
1 999950001 999996988 21988
1 999950001 999994504 19504
1 999950001 999987988 12988
1 999950001 9999...

output:

49999

result:

ok single line: '49999'

Test #4:

score: 0
Accepted
time: 336ms
memory: 119188kb

input:

1000000000 100000
1 18068 50000 6933
1 999950001 999987700 12700
1 1 3107 3107
1 18416 50000 6585
1 999981021 1000000000 18980
1 999989599 1000000000 10402
1 999981949 1000000000 18052
1 1 23318 23318
1 999950001 999977889 2889
1 999989735 1000000000 10266
1 999950001 999977002 2002
1 999977230 1000...

output:

49998

result:

ok single line: '49998'

Test #5:

score: 0
Accepted
time: 195ms
memory: 96960kb

input:

1000000000 100000
1 1 10000000 145793232
1 10000001 20000000 480576404
1 20000001 30000000 579478535
1 30000001 40000000 972724773
1 40000001 50000000 195930803
1 50000001 60000000 42390962
1 60000001 70000000 280311272
1 70000001 80000000 265006415
1 80000001 90000000 646778234
1 90000001 100000000...

output:

103256696

result:

ok single line: '103256696'

Test #6:

score: 0
Accepted
time: 189ms
memory: 98568kb

input:

1000000000 100000
1 1 1000000 84881992
1 1000001 2000000 96486607
1 2000001 3000000 87474151
1 3000001 4000000 308931873
1 4000001 5000000 752155772
1 5000001 6000000 71781449
1 6000001 7000000 574465725
1 7000001 8000000 257711828
1 8000001 9000000 976891771
1 9000001 10000000 737457473
1 10000001 ...

output:

10202525555

result:

ok single line: '10202525555'

Test #7:

score: 0
Accepted
time: 210ms
memory: 106884kb

input:

1000000000 100000
1 1 100000 691341803
1 100001 200000 909165531
1 200001 300000 998253633
1 300001 400000 186389967
1 400001 500000 182412146
1 500001 600000 620222523
1 600001 700000 290853217
1 700001 800000 77492636
1 800001 900000 595119065
1 900001 1000000 632152167
1 1000001 1100000 751499859...

output:

911635058003

result:

ok single line: '911635058003'

Test #8:

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

input:

1000000000 100000
1 1 10000000 215217992
1 10000002 20000001 257813843
1 20000003 30000002 409648986
1 30000004 40000003 74292373
1 40000005 50000004 346679152
1 50000006 60000005 168032896
1 60000007 70000006 978832613
1 70000008 80000007 972209778
1 80000009 90000008 504905160
1 90000010 100000009...

output:

-1

result:

ok single line: '-1'

Test #9:

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

input:

1000000000 100000
1 1 1000000 339975845
1 1000002 2000001 924553880
1 2000003 3000002 221514681
1 3000004 4000003 814700766
1 4000005 5000004 606897055
1 5000006 6000005 542007635
1 6000007 7000006 833481194
1 7000008 8000007 36174314
1 8000009 9000008 677730964
1 9000010 10000009 328173604
1 100000...

output:

-1

result:

ok single line: '-1'

Test #10:

score: 0
Accepted
time: 106ms
memory: 106504kb

input:

1000000000 100000
1 1 100000 546836013
1 100002 200001 79898605
1 200003 300002 355510933
1 300004 400003 613504881
1 400005 500004 608643061
1 500006 600005 346108380
1 600007 700006 94237328
1 700008 800007 615885675
1 800009 900008 144998423
1 900010 1000009 452673262
1 1000011 1100010 602954095
...

output:

-1

result:

ok single line: '-1'

Test #11:

score: 0
Accepted
time: 368ms
memory: 118124kb

input:

1000000000 100000
1 303811818 829165054 198988627
1 238315172 721819143 141698606
1 735738067 1000000000 894452247
1 361644024 743722594 115600786
1 833044862 1000000000 829396821
1 978649195 1000000000 121635824
1 656681592 1000000000 273711306
1 496003357 1000000000 145092871
1 545905300 100000000...

output:

685378438

result:

ok single line: '685378438'

Test #12:

score: 0
Accepted
time: 377ms
memory: 115024kb

input:

1000000000 100000
1 943316546 1000000000 216982980
1 19370137 444718109 622200963
1 244137695 646936606 337228786
1 721168313 1000000000 871779123
1 692826909 1000000000 475559515
1 172759072 444193083 393558194
1 902352909 1000000000 592749518
1 784704501 1000000000 46903352
1 476674919 820551472 7...

output:

8545005

result:

ok single line: '8545005'

Test #13:

score: 0
Accepted
time: 408ms
memory: 114652kb

input:

1000000000 100000
1 299540356 301014664 918798031
1 47063831 49122175 319472906
1 643593754 649240559 786327287
1 911355484 912220834 661864920
1 421773565 425654542 547070484
1 121293018 127328807 600494728
1 124896424 134073887 732623470
1 847918166 848422995 357034382
1 202634733 207639979 227135...

output:

640648629

result:

ok single line: '640648629'

Test #14:

score: 0
Accepted
time: 406ms
memory: 114292kb

input:

1000000000 100000
1 292785668 302238617 735249885
1 330242772 339770867 834706107
1 389294923 391540047 458089101
1 450680389 453059619 143967320
1 454972829 463399723 466799715
1 753057870 755431216 100716135
1 504170097 513605690 434206234
1 103062686 108678675 31594524
1 223332793 230476444 90289...

output:

566131778

result:

ok single line: '566131778'

Test #15:

score: 0
Accepted
time: 312ms
memory: 111408kb

input:

1000000000 100000
1 190249900 190686929 373454997
1 552611497 552775726 389849882
1 982934744 983745458 824523947
1 864133080 864437303 440840591
1 981480585 981574825 416048337
1 511607007 511657019 77913748
1 821534632 821810240 544332427
1 296802128 297062333 660771431
1 208063734 208493818 19912...

output:

60507750537

result:

ok single line: '60507750537'

Test #16:

score: 0
Accepted
time: 307ms
memory: 111760kb

input:

1000000000 100000
1 275121708 275841780 671595176
1 466556774 466575868 484670561
1 760216631 761110424 380331015
1 131452988 132345955 12662694
1 977640557 977642896 579869191
1 935760533 936394211 785322933
1 417528094 418262446 872043777
1 368926107 369906582 303043171
1 788412117 789358347 37981...

output:

60944102933

result:

ok single line: '60944102933'

Test #17:

score: 0
Accepted
time: 304ms
memory: 111492kb

input:

1000000000 100000
1 83134378 83939878 8
1 592189499 592792264 8
1 259250315 260076619 3
1 509562779 509615501 4
1 457433813 457988991 1
1 214916666 215313641 3
1 995959398 996917301 4
1 621550403 622406127 9
1 675067804 675700091 10
1 820894516 821281795 6
1 166308237 166609937 9
1 242380815 2431201...

output:

1663

result:

ok single line: '1663'

Test #18:

score: 0
Accepted
time: 385ms
memory: 115056kb

input:

1000000000 100000
1 943522993 1000000000 9
1 638122273 1000000000 5
1 285857010 626474643 4
1 356193761 483694746 3
1 257614831 796690153 1
1 575897497 1000000000 1
1 266218267 476247529 8
1 383225791 1000000000 2
1 561953671 1000000000 10
1 873960336 1000000000 9
1 33852012 588412399 3
1 496409891 ...

output:

4

result:

ok single line: '4'

Subtask #2:

score: 5
Accepted

Test #19:

score: 5
Accepted
time: 8ms
memory: 69692kb

input:

1 1
1000000000 1 1 1000000000

output:

1000000000

result:

ok single line: '1000000000'

Test #20:

score: 0
Accepted
time: 8ms
memory: 69656kb

input:

1000000000 16
6 2 2 1
4 999999997 999999999 4
2 999999997 1000000000 2
3 1 4 3
3 999999997 1000000000 3
5 999999998 999999999 3
6 999999999 999999999 1
2 1 4 2
6 3 999999998 1
999999987 1 1000000000 10
999999986 1 1000000000 10
999999985 1 1000000000 10
4 2 4 4
5 2 3 3
1 999999997 1000000000 1
1 1 4 1

output:

9

result:

ok single line: '9'

Test #21:

score: 0
Accepted
time: 8ms
memory: 66196kb

input:

1000000000 16
5 999999998 999999999 2
999999985 1 1000000000 8
5 2 3 3
2 1 4 2
4 2 4 3
6 3 999999998 1
1 999999997 1000000000 1
6 999999999 999999999 2
6 2 2 2
2 999999997 1000000000 2
3 999999997 1000000000 3
4 999999997 999999999 4
999999987 1 1000000000 10
1 1 4 1
999999986 1 1000000000 10
3 1 4 3

output:

8

result:

ok single line: '8'

Test #22:

score: 0
Accepted
time: 11ms
memory: 69716kb

input:

1000000000 16
200000001 3 100000003 1000000000
1 1 100000001 1000000000
400000001 5 100000005 1000000000
1 900000000 1000000000 1000000000
500000001 899999995 999999995 1000000000
500000001 6 100000006 1000000000
600000001 899999994 999999994 1000000000
700000001 500000001 999999993 1000000000
40000...

output:

16000000000

result:

ok single line: '16000000000'

Test #23:

score: 0
Accepted
time: 12ms
memory: 69656kb

input:

1000000000 16
100000001 2 100000001 1000000000
500000001 6 100000006 1000000000
300000001 899999997 999999997 1000000000
700000001 8 500000000 1000000000
400000001 899999996 999999996 1000000000
1 1 100000001 1000000000
100000001 899999999 999999999 1000000000
200000001 3 100000003 1000000000
600000...

output:

-1

result:

ok single line: '-1'

Test #24:

score: 0
Accepted
time: 8ms
memory: 69780kb

input:

1000000000 16
308520246 1 500000000 359755556
295655247 487135002 987135001 271593000
314734892 968055357 1000000000 312883746
410091097 1 500000000 101547816
395764591 485673495 985673494 629609944
392316197 982225101 1000000000 401923300
978742397 1 500000000 868693198
952345206 473602810 97360280...

output:

944232302

result:

ok single line: '944232302'

Test #25:

score: 0
Accepted
time: 4ms
memory: 70400kb

input:

1000000000 16
672706728 1 200000000 497504405
685823406 186883323 386883322 774982231
674014449 375074366 575074365 773000447
654139023 555198940 755198939 790219287
656808645 752529318 952529317 476720223
644457233 940177906 1000000000 664282982
959379929 1 200000000 786969801
978273081 181106849 3...

output:

3404859829

result:

ok single line: '3404859829'

Test #26:

score: 0
Accepted
time: 4ms
memory: 69724kb

input:

1000000000 16
540954071 1 10000000 710172197
540536129 9582059 19582058 536145072
539536499 18582429 28582428 814753471
539185649 28231579 38231578 620882859
538350203 37396133 47396132 386658616
539249992 46496344 56496343 870617207
539643763 56102573 66102572 904970863
539573301 66032111 76032110 ...

output:

-1

result:

ok single line: '-1'

Test #27:

score: 0
Accepted
time: 4ms
memory: 69844kb

input:

1000000000 16
491674089 1 500000000 336648490
539994271 451679820 951679819 469043391
517647080 929332630 1000000000 292857884
281124238 1 500000000 712418479
328708776 452415464 952415463 296084141
356807854 924316387 1000000000 648894560
660900926 1 500000000 384729282
657610483 496709559 99670955...

output:

1886981327

result:

ok single line: '1886981327'

Test #28:

score: 0
Accepted
time: 4ms
memory: 69712kb

input:

1000000000 16
838698042 1 200000000 534015959
858199116 180498928 380498927 504484211
839907744 362207557 562207556 898913833
847053449 555061853 755061852 910907433
860497726 741617577 941617576 171206653
867040700 935074604 1000000000 676192995
208351725 1 200000000 506499124
228113409 180238318 3...

output:

-1

result:

ok single line: '-1'

Test #29:

score: 0
Accepted
time: 12ms
memory: 69620kb

input:

1000000000 16
205846077 1 10000000 873895887
204858740 9012665 19012664 147782763
205674932 18196474 28196473 776792335
205398591 27920134 37920133 18876276
205275591 37797135 47797134 113374737
206002463 47070264 57070263 216570418
205456894 56524696 66524695 508488400
205480940 66500651 76500650 8...

output:

-1

result:

ok single line: '-1'

Test #30:

score: 0
Accepted
time: 8ms
memory: 69680kb

input:

1000000000 16
521719332 635760132 934417526 529743702
1305373 525299245 1000000000 461248301
101171661 237013303 513442486 519226146
461851512 227481783 939390202 642026488
835321835 380826656 1000000000 864581393
774758954 598049287 1000000000 885982602
476039441 1 226851442 609871787
583465229 392...

output:

1071400261

result:

ok single line: '1071400261'

Test #31:

score: 0
Accepted
time: 9ms
memory: 69660kb

input:

1000000000 16
206783888 1 794031651 473137665
654757441 181608545 482154540 814079812
199299059 172003379 589586500 977531496
445754685 647415391 1000000000 724703815
30495945 650569357 1000000000 700408250
370373056 15814055 569148871 97147596
592280811 734763422 1000000000 99025581
523660734 98269...

output:

926766012

result:

ok single line: '926766012'

Test #32:

score: 0
Accepted
time: 12ms
memory: 69692kb

input:

1000000000 16
53129883 43438614 576626916 420027795
595715370 217546351 904088926 117669374
501698138 394506898 1000000000 501348919
16794543 467166832 1000000000 430252715
66170783 44326969 740935026 307666284
100432574 105218928 612739989 964426597
66832107 59260547 587707946 695056263
71803431 40...

output:

1084276058

result:

ok single line: '1084276058'

Test #33:

score: 0
Accepted
time: 5ms
memory: 70172kb

input:

20 16
11 11 20 614196799
18 11 20 106915074
9 20 20 806710174
5 19 20 334176271
12 11 16 63935383
8 1 3 493767973
13 17 20 937825697
16 11 20 599156261
4 6 20 162982558
17 4 20 156235818
12 8 14 967709279
19 11 20 880182565
6 13 18 842507131
19 17 19 30861075
17 1 10 659432307
9 5 15 689432411

output:

815668125

result:

ok single line: '815668125'

Test #34:

score: 0
Accepted
time: 9ms
memory: 69636kb

input:

20 16
14 1 5 36860000
17 3 8 100853922
6 14 16 960259663
20 2 9 15251465
8 17 18 411813150
16 18 20 957718939
17 1 8 346305175
2 20 20 759532534
3 16 20 708800301
12 19 20 571134941
5 4 11 532379718
6 16 20 124294312
20 12 20 89050063
16 13 19 890357065
20 13 20 289577457
15 20 20 126485192

output:

-1

result:

ok single line: '-1'

Test #35:

score: 0
Accepted
time: 7ms
memory: 70040kb

input:

20 16
5 17 20 883046038
2 13 15 646298453
1 16 19 673045363
5 8 9 429038258
5 4 7 675052934
3 9 11 556330641
4 7 11 709314017
2 18 20 666670231
1 3 3 408856853
2 2 6 619870732
2 12 14 948839865
2 10 13 131394079
2 2 2 70988341
3 1 3 17741436
5 14 14 901591370
2 17 19 223748049

output:

-1

result:

ok single line: '-1'

Test #36:

score: 0
Accepted
time: 6ms
memory: 70112kb

input:

20 16
8 17 19 6
11 1 12 19
20 15 20 18
16 13 20 13
12 6 16 9
14 2 19 3
5 10 13 16
7 18 18 20
5 11 20 11
11 7 20 11
13 18 20 15
9 7 16 3
13 1 4 11
5 12 20 2
11 13 16 20
11 14 19 7

output:

19

result:

ok single line: '19'

Test #37:

score: 0
Accepted
time: 8ms
memory: 70388kb

input:

20 16
4 8 12 1
5 3 3 3
3 1 3 2
5 1 3 2
5 20 20 2
5 8 8 2
4 7 11 2
1 8 9 4
1 8 10 5
5 20 20 3
4 12 16 4
5 6 7 3
5 8 8 3
5 15 18 3
1 19 20 5
1 2 2 1

output:

-1

result:

ok single line: '-1'

Subtask #3:

score: 30
Accepted

Dependency #2:

100%
Accepted

Test #38:

score: 30
Accepted
time: 12ms
memory: 71268kb

input:

1000000000 5000
2157 2 343 342
684 999998751 1000000000 684
1022 999998751 1000000000 1022
991 999998751 1000000000 991
2291 999999792 999999999 208
47 1 1250 47
402 999998751 1000000000 402
1688 999999189 999999999 811
987 1 1250 987
1606 999999107 999999999 893
2304 999999805 999999999 195
685 999...

output:

2499

result:

ok single line: '2499'

Test #39:

score: 0
Accepted
time: 21ms
memory: 71248kb

input:

1000000000 5000
195 1 1250 195
564 1 1250 564
129 999998751 1000000000 129
1682 999999183 999999999 817
2204 2 296 295
1035 999998751 1000000000 1035
847 999998751 1000000000 847
1476 999998977 999999999 1023
1811 999999312 999999999 688
2472 2 28 27
1319 999998820 999999999 1180
61 1 1250 61
78 999...

output:

2498

result:

ok single line: '2498'

Test #40:

score: 0
Accepted
time: 21ms
memory: 71076kb

input:

1000000000 5000
757999622 10002618 12002617 1000000000
295999853 4001147 6001146 1000000000
379999811 12003185 14003184 1000000000
103999949 2000949 4000948 1000000000
565999718 18004710 20004709 1000000000
197999902 10002898 12002897 1000000000
335999833 169 2000168 1000000000
355999823 12003173 14...

output:

5000000000000

result:

ok single line: '5000000000000'

Test #41:

score: 0
Accepted
time: 13ms
memory: 70976kb

input:

1000000000 5000
217999892 18004884 20004883 1000000000
91999955 12003041 14003040 1000000000
725999638 18004630 20004629 1000000000
601999700 8002298 10002297 1000000000
437999782 14003776 16003775 1000000000
265999868 4001132 6001131 1000000000
889999556 2000556 4000555 1000000000
937999532 470 200...

output:

-1

result:

ok single line: '-1'

Test #42:

score: 0
Accepted
time: 14ms
memory: 71264kb

input:

1000000000 5000
320666835 1 200000000 187217853
322526939 198139897 398139896 631767388
323529367 397137469 597137468 496959374
321841766 595449868 795449867 620561126
322858692 794432942 994432941 681543718
323529475 993762159 1000000000 986545860
885805421 1 200000000 676801183
886545538 199259884...

output:

123063672

result:

ok single line: '123063672'

Test #43:

score: 0
Accepted
time: 16ms
memory: 71872kb

input:

1000000000 5000
745611209 1 20000000 715651313
745680002 19931208 39931207 402698748
745755872 39855338 59855337 288321567
745938511 59672699 79672698 602888599
745770728 79504916 99504915 659069258
745685242 99419430 119419429 273198983
745562217 119296405 139296404 178746774
745546744 139280932 15...

output:

14163571828

result:

ok single line: '14163571828'

Test #44:

score: 0
Accepted
time: 21ms
memory: 71160kb

input:

1000000000 5000
112753424 1 2000000 913062593
112739395 1985972 3985971 166281708
112730420 3976997 5976996 580451332
112721071 5967648 7967647 561368637
112716937 7963514 9963513 715676377
112732367 9948084 11948083 537584086
112741031 11939420 13939419 292675267
112741126 13939325 15939324 3439499...

output:

248584753293

result:

ok single line: '248584753293'

Test #45:

score: 0
Accepted
time: 9ms
memory: 71556kb

input:

1000000000 5000
808230331 1 300000 43999410
808231945 298387 598386 90475405
808230452 596894 896893 876469028
808227612 894054 1194053 922246629
808228360 1193306 1493305 179771938
808229492 1492174 1792173 278935746
808228404 1791086 2091085 892173746
808231066 2088424 2388423 128812805
808233395 ...

output:

1683442292004

result:

ok single line: '1683442292004'

Test #46:

score: 0
Accepted
time: 24ms
memory: 71880kb

input:

1000000000 5000
401249082 1 200000000 920491430
399495207 198246127 398246126 249417395
399826536 397914799 597914798 748877841
400752881 596988455 796988454 907417173
402159614 795581723 995581722 135958240
403539588 994201750 1000000000 25492362
671577003 1 200000000 777341154
672292425 199284580 ...

output:

186911801

result:

ok single line: '186911801'

Test #47:

score: 0
Accepted
time: 25ms
memory: 71140kb

input:

1000000000 5000
232472239 1 20000000 713761443
232392941 19920704 39920703 741651619
232501468 39812178 59812177 14498992
232399063 59709774 79709773 999129630
232398402 79709114 99709113 887346137
232311738 99622451 119622450 150396004
232469824 119464366 139464365 633967062
232372864 139367407 159...

output:

50513374632

result:

ok single line: '50513374632'

Test #48:

score: 0
Accepted
time: 11ms
memory: 71632kb

input:

1000000000 5000
383539588 1 2000000 196715675
383533267 1993681 3993680 264028353
383520149 3980564 5980563 262446104
383503405 5963821 7963820 607613258
383521627 7945600 9945599 543170680
383513509 9937483 11937482 695813979
383517437 11933556 13933555 282402610
383529983 13921011 15921010 1361849...

output:

-1

result:

ok single line: '-1'

Test #49:

score: 0
Accepted
time: 11ms
memory: 71092kb

input:

1000000000 5000
726375412 1 300000 351886860
726373843 298433 598432 606710275
726373467 598058 898057 697117103
726375744 895782 1195781 190941467
726377079 1194448 1494447 656368106
726379835 1491693 1791692 375013198
726380226 1791303 2091302 973079150
726383110 2088420 2388419 836103301
72638396...

output:

-1

result:

ok single line: '-1'

Test #50:

score: 0
Accepted
time: 20ms
memory: 71244kb

input:

1000000000 5000
671385932 191166426 574562428 819068448
416904809 882132733 1000000000 445015983
882601166 773100419 1000000000 680649449
289832356 507463117 1000000000 402881354
893638448 382183115 859270310 294271111
180793943 817397728 1000000000 780380576
123575156 663535344 877510038 118371373
...

output:

620783455

result:

ok single line: '620783455'

Test #51:

score: 0
Accepted
time: 20ms
memory: 71596kb

input:

1000000000 5000
99450 344354789 1000000000 729115481
927422 299870321 378553946 514527062
935604 10676391 70216351 29268923
468308 338280859 386146861 232446023
490002 53418218 403888826 873541966
190796 524972303 1000000000 234913438
191467 183894576 767698203 454389112
893679 834068169 1000000000 ...

output:

161589786

result:

ok single line: '161589786'

Test #52:

score: 0
Accepted
time: 13ms
memory: 71656kb

input:

1000000000 5000
444 52389522 61880965 139385
4419 516783503 520980606 465435995
2780 866790887 875891659 371084291
1325 892480383 894980778 722763168
2331 593580028 601723156 189138320
1095 260328208 267441089 470387484
3469 126734096 136062224 500271727
748 120626888 129161489 525354866
4149 150764...

output:

12146871901

result:

ok single line: '12146871901'

Test #53:

score: 0
Accepted
time: 23ms
memory: 71304kb

input:

1000000000 5000
312791758 633717514 934039952 6
813610687 963644804 1000000000 3
993908575 752408978 1000000000 5
499538805 975159739 1000000000 1
976331544 810280188 1000000000 8
241457781 552997077 584011452 8
466166985 490564740 761892078 3
834562158 502538343 820561438 9
181289127 909382403 1000...

output:

2

result:

ok single line: '2'

Test #54:

score: 0
Accepted
time: 24ms
memory: 71932kb

input:

1000000000 5000
802937 787859444 790890981 3
122444 52886017 158152359 4
935119 523480777 1000000000 3
186748 456804343 986555414 6
757695 758426090 1000000000 4
828815 311815954 355318073 3
776915 942265819 1000000000 10
507072 527244135 686310255 5
27186 67238838 314997238 10
979059 596366396 7604...

output:

3

result:

ok single line: '3'

Test #55:

score: 0
Accepted
time: 20ms
memory: 71220kb

input:

1000000000 5000
1200 731737246 733911664 4
3161 777049953 780912302 10
4546 950327002 952835432 4
2747 11761580 13314493 3
446 980032453 983209259 2
4342 85921856 93203729 4
3231 87962829 91383678 9
3808 963865247 973447644 4
3864 834694059 837127707 5
3281 432100113 433971672 10
1892 947160670 9563...

output:

228

result:

ok single line: '228'

Subtask #4:

score: 61
Accepted

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

100%
Accepted

Test #56:

score: 61
Accepted
time: 294ms
memory: 114744kb

input:

1000000000 100000
2262 999975001 1000000000 2262
4570 999975001 1000000000 4570
47444 2 2556 2555
33702 999983703 999999999 16297
2010 999975001 1000000000 2010
9963 1 25000 9963
3273 1 25000 3273
48228 999998229 999999999 1771
40314 999990315 999999999 9685
43630 2 6370 6369
8497 1 25000 8497
46106...

output:

49999

result:

ok single line: '49999'

Test #57:

score: 0
Accepted
time: 395ms
memory: 114960kb

input:

1000000000 100000
999962091 2 12090 12089
999989486 1 25000 10515
999992348 1 25000 7653
999998160 1 25000 1841
999994479 999975001 1000000000 5522
999960012 999989990 999999999 10010
999954869 999995133 999999999 4867
999968096 2 18095 18094
999984383 1 25000 15618
999991200 1 25000 8801
999998572 ...

output:

49999

result:

ok single line: '49999'

Test #58:

score: 0
Accepted
time: 275ms
memory: 109176kb

input:

1000000000 100000
8497 999999658 999999974 316
41639 132 448 316
16984 54 370 316
48602 999999531 999999847 316
13434 43 359 316
694 3 319 316
10517 999999651 999999967 316
7119 999999662 999999978 316
35105 999999573 999999889 316
2128 999999678 999999994 316
399 999999683 999999999 316
9250 999999...

output:

99225

result:

ok single line: '99225'

Test #59:

score: 0
Accepted
time: 262ms
memory: 109204kb

input:

1000000000 100000
999957210 136 452 316
999978000 999999615 999999931 316
999977743 999999614 999999930 316
999966428 107 423 316
999960172 999999558 999999874 316
999980253 63 379 316
999986390 999999641 999999957 316
999990532 999999655 999999971 316
999980935 999999624 999999940 316
999963626 116...

output:

99225

result:

ok single line: '99225'

Test #60:

score: 0
Accepted
time: 232ms
memory: 106164kb

input:

1000000000 100000
778192219 447783 547782 1000000000
267697324 557324 657323 1000000000
351996481 663521 763520 1000000000
165698344 661658 761657 1000000000
356296438 663564 763563 1000000000
592694074 665928 765927 1000000000
670493296 113296 213295 1000000000
631893682 666320 766319 1000000000
34...

output:

100000000000000

result:

ok single line: '100000000000000'

Test #61:

score: 0
Accepted
time: 255ms
memory: 108232kb

input:

1000000000 100000
17108 999999630 999999946 316
12192 999999646 999999962 316
4868 16 332 316
7833 25 341 316
33503 107 423 316
29558 999999591 999999907 316
17006 54 370 316
30616 999999588 999999904 316
20070 64 380 316
2738 9 325 316
8864 999999656 999999972 316
2694 999999676 999999992 316
13891...

output:

99224

result:

ok single line: '99224'

Test #62:

score: 0
Accepted
time: 301ms
memory: 114864kb

input:

1000000000 100000
33473 999983474 999999999 16526
40411 2 9589 9588
11943 999975001 1000000000 11943
42033 2 7967 7966
44807 999994808 999999999 5192
37416 999987417 999999999 12583
47983 999997984 999999999 2016
21138 1 25000 21138
2564 1 25000 2564
596 999975001 1000000000 596
897 1 25000 897
5892...

output:

49998

result:

ok single line: '49998'

Test #63:

score: 0
Accepted
time: 192ms
memory: 103584kb

input:

1000000000 100000
327227275 32727 42726 1000000000
663103684 66318 76317 1000000000
506639332 50670 60669 1000000000
421327864 42138 52137 1000000000
298000198 29804 39803 1000000000
57224278 5724 15723 1000000000
776102383 77619 87618 1000000000
12248776 1226 11225 1000000000
881661826 88176 98175 ...

output:

100000000000000

result:

ok single line: '100000000000000'

Test #64:

score: 0
Accepted
time: 205ms
memory: 104392kb

input:

1000000000 100000
944315569 5570 15569 1000000000
485281477 51478 61477 1000000000
42505759 95760 105759 1000000000
442865719 55720 65719 1000000000
35316478 96479 106478 1000000000
199720036 80037 90036 1000000000
816998302 18303 28302 1000000000
55044505 94506 104505 1000000000
839906011 16012 260...

output:

100000000000000

result:

ok single line: '100000000000000'

Test #65:

score: 0
Accepted
time: 236ms
memory: 110920kb

input:

1000000000 100000
9999 282150000 282169998 1000000000
9999 526150000 526169998 1000000000
1 575500001 575519999 1000000000
1 511580001 511599999 1000000000
1 503860001 503879999 1000000000
9999 959210000 959229998 1000000000
9999 278710000 278729998 1000000000
1 224000001 224019999 1000000000
1 7230...

output:

100000000000000

result:

ok single line: '100000000000000'

Test #66:

score: 0
Accepted
time: 194ms
memory: 106964kb

input:

1000000000 100000
763192369 992369 1092368 1000000000
147698524 441478 541477 1000000000
149398507 778507 878506 1000000000
329896702 336702 436701 1000000000
674393257 993257 1093256 1000000000
939690604 669398 769397 1000000000
741192589 667413 767412 1000000000
256197439 662563 762562 1000000000
...

output:

-1

result:

ok single line: '-1'

Test #67:

score: 0
Accepted
time: 394ms
memory: 110540kb

input:

1000000000 100000
285370413 1 10000000 871735847
285387980 9982434 19982433 479942807
285413608 19956806 29956805 727043934
285387769 29930967 39930966 718067722
285387494 39930692 49930691 681881260
285400683 49917503 59917502 670901143
285437007 59881179 69881178 129003158
285367313 69811485 79811...

output:

14612273644

result:

ok single line: '14612273644'

Test #68:

score: 0
Accepted
time: 335ms
memory: 110316kb

input:

1000000000 100000
527850384 1 1000000 248343082
527857387 992998 1992997 894761316
527852445 1988056 2988055 420765794
527850544 2986155 3986154 340602477
527857815 3978884 4978883 174350806
527862181 4974518 5974517 30500767
527866503 5970196 6970195 572390733
527867277 6969422 7969421 29718857
527...

output:

391238206896

result:

ok single line: '391238206896'

Test #69:

score: 0
Accepted
time: 250ms
memory: 111048kb

input:

1000000000 100000
931204204 1 100000 492437569
931204694 99511 199510 231045553
931204900 199305 299304 346655450
931205393 298812 398811 798953855
931204521 397940 497939 112150507
931204531 497930 597929 941804358
931204339 597738 697737 513801608
931204635 697442 797441 252895999
931204112 796919...

output:

4969487159950

result:

ok single line: '4969487159950'

Test #70:

score: 0
Accepted
time: 437ms
memory: 109432kb

input:

1000000000 100000
788985947 1 10000000 229287371
793829492 5156456 15156455 604510013
792490217 13817181 23817180 330138629
796903640 19403758 29403757 270892997
793972674 26472792 36472791 995517978
790678306 33178424 43178423 141926111
791993600 41863130 51863129 585864559
791795200 51664730 61664...

output:

11362007391

result:

ok single line: '11362007391'

Test #71:

score: 0
Accepted
time: 310ms
memory: 110376kb

input:

1000000000 100000
812462402 1 1000000 627303503
812086398 623997 1623996 883412574
812435109 1275286 2275285 154189178
812424165 2264342 3264341 572665314
812347024 3187201 4187200 63443474
811997645 3837822 4837821 965367653
811625178 4465355 5465354 888152840
811830109 5260424 6260423 881040863
81...

output:

575864265341

result:

ok single line: '575864265341'

Test #72:

score: 0
Accepted
time: 252ms
memory: 110436kb

input:

1000000000 100000
293020540 1 100000 555406819
292993391 72852 172851 691081038
292978253 157714 257713 524422180
292949691 229152 329151 397900707
292918715 298176 398175 801357740
292946131 370760 470759 614570027
292907054 431683 531682 881805559
292942754 495983 595982 293868654
292912529 565758...

output:

6599557600581

result:

ok single line: '6599557600581'

Test #73:

score: 0
Accepted
time: 394ms
memory: 110420kb

input:

1000000000 100000
291936561 1 10000000 157747231
290517635 8581076 18581075 945889660
289630206 17693648 27693647 915511843
291546003 25777852 35777851 598043035
290380243 34612093 44612092 47005937
287534962 41766813 51766812 510601311
286871337 51103189 61103188 395538676
288273402 59701125 697011...

output:

13617321012

result:

ok single line: '13617321012'

Test #74:

score: 0
Accepted
time: 135ms
memory: 109932kb

input:

1000000000 100000
960703819 1 1000000 958371816
961006620 697201 1697200 909126779
961349217 1354605 2354604 803229999
961584473 2119350 3119349 30717718
961872889 2830935 3830934 467317421
961887626 3816199 4816198 774606110
962235302 4468524 5468523 694228998
962123954 5357177 6357176 337523173
96...

output:

-1

result:

ok single line: '-1'

Test #75:

score: 0
Accepted
time: 122ms
memory: 110220kb

input:

1000000000 100000
283175496 1 100000 87590504
283204815 70683 170682 700146537
283238246 137253 237252 574143151
283272579 202921 302920 860243942
283295358 280143 380142 922400863
283269862 354648 454647 346901229
283279384 445127 545126 82457877
283278685 544429 644428 679853691
283229315 595060 6...

output:

-1

result:

ok single line: '-1'

Test #76:

score: 0
Accepted
time: 403ms
memory: 116772kb

input:

1000000000 100000
1254 622754869 1000000000 484342268
8293 98279236 431567095 875482249
9401 501769010 1000000000 372222508
19031 904353654 1000000000 842592138
19069 796234859 936081966 867049707
25969 872856151 1000000000 282472001
94580 441207050 1000000000 560635372
7305 793798814 1000000000 631...

output:

80841068

result:

ok single line: '80841068'

Test #77:

score: 0
Accepted
time: 482ms
memory: 115252kb

input:

1000000000 100000
99953866 945075973 1000000000 649119238
326742787 740650069 1000000000 169352197
131952562 357264696 972464965 152451166
378502375 900132774 1000000000 820333522
124873512 484619373 549262009 631022515
136101329 847164827 1000000000 29741024
177228488 770538908 1000000000 555017600...

output:

7323756

result:

ok single line: '7323756'

Test #78:

score: 0
Accepted
time: 407ms
memory: 113568kb

input:

1000000000 100000
15933 344837054 346354774 495934399
73063 804753101 808498938 817179421
98557 499837345 502746557 455342931
92436 430449420 438167422 235695654
45294 604481890 609409831 279131879
66053 327705160 329060071 679900866
68500 851897683 855982145 347177971
3767 724663639 726890714 75198...

output:

735250010

result:

ok single line: '735250010'

Test #79:

score: 0
Accepted
time: 418ms
memory: 110180kb

input:

1000000000 100000
743010166 936525917 946068272 855063665
930335680 797533984 807020213 716981312
661267193 234608973 240461704 950509114
316965439 28876194 37889497 102206217
620128621 828132108 829903443 342194497
89342827 235146498 244269202 184886299
446374583 397984769 405590314 974287365
94959...

output:

66691199500

result:

ok single line: '66691199500'

Test #80:

score: 0
Accepted
time: 320ms
memory: 111272kb

input:

1000000000 100000
91206 785548652 785662027 352967881
53511 656277772 656704572 130067443
64483 913704102 914634177 58943194
93206 159302183 159926583 125223938
12869 459091163 459368302 206822497
64834 443831227 444557596 329610922
66113 249607274 250463853 646126443
83970 605978878 606075457 84484...

output:

67306499584

result:

ok single line: '67306499584'

Test #81:

score: 0
Accepted
time: 140ms
memory: 109976kb

input:

1000000000 100000
695166134 114908469 117075779 869674926
251955207 653262426 653679938 694707794
266402713 133627028 133893278 332530425
534489715 656745869 657305167 445852584
539630530 348430309 352047851 302938326
863578278 820244127 823044481 510284538
671256817 585482496 587487215 579861739
71...

output:

-1

result:

ok single line: '-1'

Test #82:

score: 0
Accepted
time: 331ms
memory: 110820kb

input:

1000000000 100000
36362 889608594 891413373 2
39459 510379988 514046219 6
18158 843407828 850712675 7
90234 253655872 261826019 4
6906 654472905 662624739 4
45306 417966516 423792170 3
14799 289083051 290147553 7
84245 537382640 545197495 8
79606 396456211 398430344 10
74092 332430587 341801088 5
80...

output:

116

result:

ok single line: '116'

Test #83:

score: 0
Accepted
time: 362ms
memory: 110312kb

input:

1000000000 100000
3465915 770774220 773876342 10
5128785 920543552 921630216 5
8600768 90850169 97465532 5
214935 856916364 864667358 9
4694752 708428117 709355987 10
6366503 313638205 322391035 3
8464393 44662508 48145563 9
9779276 591370066 593857587 1
5183234 666115832 669007146 4
1887421 8508274...

output:

135

result:

ok single line: '135'

Test #84:

score: 0
Accepted
time: 432ms
memory: 110128kb

input:

1000000000 100000
522971410 688293516 697214175 2
116084809 113531558 116487517 9
526373026 89685996 96866918 3
914894654 935795701 944075463 2
702705712 592039095 600102521 7
879862015 274198796 282954012 1
622588741 792745030 801324484 1
25492759 544729064 545452255 10
592263541 234032835 24193894...

output:

758

result:

ok single line: '758'

Test #85:

score: 0
Accepted
time: 227ms
memory: 111060kb

input:

1000000000 100000
426317497 535947432 535991214 310120053
676235003 530803018 530845605 554235754
441275222 418612057 418704915 376047522
490212558 516305429 516342482 140836931
178151734 386999945 387081548 717087691
197321211 204456405 204511126 902340964
878225077 922046447 922106631 195775575
78...

output:

14989898833679

result:

ok single line: '14989898833679'

Test #86:

score: 0
Accepted
time: 260ms
memory: 110028kb

input:

1000000000 100000
868898393 701056733 701142952 716490994
718709997 297309810 297386537 700226084
10574345 435898824 435942639 700828336
157833609 854633732 854711620 127963417
706969521 691658802 691718096 681027159
646631352 369427928 369476900 208974289
101959665 381872794 381967348 3545996
88621...

output:

14975521107938

result:

ok single line: '14975521107938'

Test #87:

score: 0
Accepted
time: 245ms
memory: 110208kb

input:

1000000000 100000
302917203 860752123 860887083 946727248
842071404 262227048 262424280 704304270
5255251 173972075 174117409 146765442
103704617 87765191 87944430 585292863
118628426 799623224 799687463 133353308
115295936 371832963 371927049 603635019
111437898 909862149 910022254 589092950
415263...

output:

7450046412360

result:

ok single line: '7450046412360'

Test #88:

score: 0
Accepted
time: 248ms
memory: 110712kb

input:

1000000000 100000
863849283 460675127 460739645 422034388
869840937 742624945 742698594 365654271
860515527 254651611 254735010 699587624
868125291 606445219 606497652 745472985
866378087 542260706 542321155 923491227
864915089 517938193 517997978 377607488
863717141 316527687 316599057 745797830
86...

output:

8163075003639

result:

ok single line: '8163075003639'

Test #89:

score: 0
Accepted
time: 244ms
memory: 110120kb

input:

1000000000 100000
685963892 836655109 836741056 153707275
162789934 150563404 150648792 509256497
825144340 917264408 917337210 736387699
648283077 988072344 988116263 907214920
904591922 278124229 278208919 429861410
548410400 260647438 260721608 230747666
267054061 677187 773519 292752500
80479749...

output:

12546457489715

result:

ok single line: '12546457489715'

Test #90:

score: 0
Accepted
time: 475ms
memory: 114076kb

input:

1000000000 100000
940222992 193506237 193598877 860853689
944154163 227897407 227992377 355009586
938134698 99390718 99466601 91087731
939132407 48525590 48603190 698583552
494591572 136235489 136379730 790125434
944194620 778987300 779026076 401751681
458378757 144738504 144919661 892685882
1906424...

output:

164858591923

result:

ok single line: '164858591923'

Test #91:

score: 0
Accepted
time: 370ms
memory: 111720kb

input:

1000000000 100000
434461083 637571934 639223657 934496599
177318355 236473249 238768882 670032729
155749373 541251065 542776412 216263977
398888651 830738095 833641544 497648845
970148188 768467985 770736307 933161279
590757846 716720376 718774530 503006207
672093687 949645356 951047200 179943634
98...

output:

2520406831

result:

ok single line: '2520406831'

Test #92:

score: 0
Accepted
time: 258ms
memory: 110168kb

input:

1000000000 100000
953972716 847602734 849521562 517016092
398866195 851236355 853016492 298868841
720734924 303829309 305303289 189171870
680490528 710708717 712816254 652963686
156845527 37359922 38383633 673009672
735888147 936080484 938599150 645195466
155908612 90386908 92997328 517533117
898004...

output:

485887211638

result:

ok single line: '485887211638'

Test #93:

score: 0
Accepted
time: 376ms
memory: 110268kb

input:

1000000000 100000
708247243 58977615 63864225 130703666
250200326 86532297 90491541 943580884
640042080 797783949 802070662 56175080
920441185 838825488 841030743 422262196
357650425 475593222 479938762 854243426
305023050 178666191 180841048 394294913
458406603 398187242 402200193 471155254
8031473...

output:

152545386832

result:

ok single line: '152545386832'

Test #94:

score: 0
Accepted
time: 350ms
memory: 108772kb

input:

1000000000 100000
176295403 911319245 912565166 182543067
176692949 807369783 808801849 607532818
176576517 904367698 906629926 490136581
164987612 855126624 857949067 624326301
180395520 643617283 646583168 325023452
169476158 107520706 108918053 236926223
181582537 534401669 537265628 694578369
16...

output:

18742231933

result:

ok single line: '18742231933'

Test #95:

score: 0
Accepted
time: 329ms
memory: 109692kb

input:

1000000000 100000
481522732 996360881 998389763 68759306
874773968 939245960 940411139 97109050
360033570 233523917 234767927 298466142
90555284 995984323 997511785 432128016
331624235 261710879 263179936 548877154
75165219 43064282 44895467 999562627
648200290 120043775 121196444 972687415
33331259...

output:

390009241327

result:

ok single line: '390009241327'

Test #96:

score: 0
Accepted
time: 517ms
memory: 114360kb

input:

1000000000 100000
233084112 262009178 262162402 904829656
123976158 192714527 192907119 45823681
64477941 643864573 643962186 467079714
479504831 983985144 984035287 855942268
231851592 81149042 81346497 951253996
634932737 651989744 652101501 587503282
70737585 240804521 797520718 170575059
3777660...

output:

4951357253

result:

ok single line: '4951357253'

Test #97:

score: 0
Accepted
time: 535ms
memory: 115060kb

input:

1000000000 100000
953652634 347580466 620654486 483080249
231598858 693695564 946646298 778894111
635641549 209071240 402176456 448570239
113863022 169635929 350004879 170243992
315618687 655912156 809616365 10136903
852287952 182749052 461566585 717433107
510212023 437425443 619090031 723263768
366...

output:

974984227

result:

ok single line: '974984227'

Test #98:

score: 0
Accepted
time: 496ms
memory: 115252kb

input:

1000000000 100000
12950426 54120720 191201327 253890229
831903532 238962377 473466607 797616143
712328224 224139083 410184685 635067565
862055213 455344669 592632036 848829276
236014437 260280059 363091441 124402187
34387390 328888073 568866862 117837330
887738115 705680643 942203901 332078369
81457...

output:

92063195

result:

ok single line: '92063195'

Test #99:

score: 0
Accepted
time: 497ms
memory: 114436kb

input:

1000000000 100000
805520259 458444347 603696791 540899388
262404124 649785199 819975236 281962244
693012675 101989552 344777784 765709433
710690377 772820148 1000000000 402350679
311605080 503420073 620929567 254695335
719913128 160643593 391636599 702601756
496813220 131898762 299304138 578181679
4...

output:

749516152

result:

ok single line: '749516152'

Test #100:

score: 0
Accepted
time: 444ms
memory: 110308kb

input:

1000000000 100000
95367993 840762869 1000000000 490543754
43449511 377776362 482268967 788673056
220197074 814593213 1000000000 389574353
219573254 813969393 1000000000 517027537
237001356 998352320 1000000000 377835633
173714739 221673169 432299153 234676248
136218369 184176799 379760321 570742553
...

output:

1114321

result:

ok single line: '1114321'

Test #101:

score: 0
Accepted
time: 479ms
memory: 114380kb

input:

1000000000 100000
81535211 860813459 998454493 241452379
414378704 77599896 322571906 648485931
406227276 45144758 232669417 279373614
210749838 816792597 970911209 464181429
956619087 22329682 231874573 528009923
109360841 53319003 313585265 904998770
898919571 167296956 316280574 597440701
6355349...

output:

629462032

result:

ok single line: '629462032'

Test #102:

score: 0
Accepted
time: 454ms
memory: 115588kb

input:

1000000000 100000
206785006 393196697 1000000000 711971430
440882028 136851801 1000000000 195775475
535541670 14565853 493923473 190474657
24535752 36747842 841749607 893659286
60336706 20594172 580058648 648192988
553227091 168498608 1000000000 327951855
618080091 193693810 816261680 104615267
1196...

output:

588641480

result:

ok single line: '588641480'

Test #103:

score: 0
Accepted
time: 288ms
memory: 111012kb

input:

1000000000 100000
450669643 726253314 726421567 112118057
910126002 22213471 22241831 250068965
173791569 316601779 316619329 597584829
953557907 440238389 440382184 227063377
473457119 926039178 926085831 299215987
407479522 223009346 223099914 538670298
969562691 683436781 683465613 642722025
8109...

output:

5338370499

result:

ok single line: '5338370499'

Extra Test:

score: 0
Extra Test Passed