QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#524123#5041. FireJEdwardAC ✓55ms33240kbC++171.8kb2024-08-19 10:53:482024-08-19 10:53:48

Judging History

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

  • [2024-08-19 10:53:48]
  • 评测
  • 测评结果:AC
  • 用时:55ms
  • 内存:33240kb
  • [2024-08-19 10:53:48]
  • 提交

answer

#include <bits/stdc++.h>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;

const int N = 100010;

int n, k;
int a[N], s[N];
ll x[N], y[N];
vector<int> g[N];
vector<pair<pair<ll, int>, int>> greedy[N];

void dfs(int u) {
  s[u] = 1;
  for (int v : g[u])
    if (!s[v]) {
      dfs(v);
      s[u] += s[v];
      greedy[u].emplace_back(make_pair(x[v] - 1, s[v] * 2), v);
    }
  sort(greedy[u].begin(), greedy[u].end(), [&](const pair<pair<ll, int>, int>& lhs, const pair<pair<ll, int>, int>& rhs) { return rhs.first.first - lhs.first.second > lhs.first.first - rhs.first.second; });
  int d = greedy[u].size();
  vector<ll> dp;
  dp.push_back(numeric_limits<ll>::max());
  int pre = 0;
  x[u] = a[u] + min(k - 2 * s[u], 0);
  for (const auto& pr : greedy[u]) {
    x[u] = min(x[u], pr.first.first - pre);
    dp.push_back(min(dp.back(), pr.first.first - pre));
    pre += pr.first.second;
  }
  if (d) {
    vector<ll> suf(d + 1);
    suf[d] = numeric_limits<ll>::max();
    for (int i = d - 1; i >= 0; --i)
      suf[i] = min(suf[i + 1] - greedy[u][i].first.second, greedy[u][i].first.first);
    y[u] = numeric_limits<ll>::min();
    pre = 0;
    for (int i = 0; i < d; ++i) {
      int v = greedy[u][i].second;
      y[u] = max(y[u], min({y[v] - 2 * (s[u] - s[v] - 1) - 1, suf[i + 1] - pre, dp[i], (ll)a[u], a[u] + k - 2LL * (s[u] - s[v])}));
      pre += greedy[u][i].first.second;
    }
  } else
    y[u] = a[u];
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n >> k;
  for (int rep = 1; rep < n; ++rep) {
    int u, v;
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  for (int i = 1; i <= n; ++i) cin >> a[i];
  dfs(1);
  cout << max(-1LL, y[1]) << '\n';
  return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 9760kb

input:

3 1
1 2
1 3
4 3 5

output:

1

result:

ok 1 number(s): "1"

Test #2:

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

input:

3 1
1 2
1 3
2 10 10

output:

-1

result:

ok 1 number(s): "-1"

Test #3:

score: 0
Accepted
time: 2ms
memory: 9064kb

input:

2 0
1 2
10 10

output:

8

result:

ok 1 number(s): "8"

Test #4:

score: 0
Accepted
time: 2ms
memory: 9480kb

input:

3 0
1 2
3 1
10 8 10

output:

5

result:

ok 1 number(s): "5"

Test #5:

score: 0
Accepted
time: 2ms
memory: 9556kb

input:

10 0
9 7
2 7
2 1
4 7
9 6
7 3
8 10
9 10
8 5
29 24 27 22 20 25 23 29 20 20

output:

8

result:

ok 1 number(s): "8"

Test #6:

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

input:

100 0
82 86
79 53
86 24
64 74
3 26
65 91
47 35
73 90
8 75
59 27
78 19
76 20
34 7
82 31
11 20
4 85
52 16
46 51
93 52
87 20
82 6
64 92
52 2
54 62
60 63
69 95
24 90
54 25
9 72
2 20
27 82
29 25
43 85
57 92
36 77
22 81
14 84
69 49
20 47
52 98
97 88
23 45
1 87
56 45
31 36
85 31
44 83
33 53
10 78
37 40
13 ...

output:

52

result:

ok 1 number(s): "52"

Test #7:

score: 0
Accepted
time: 2ms
memory: 9508kb

input:

1000 0
781 478
708 997
164 3
242 868
210 828
349 149
376 785
332 690
182 514
552 322
461 542
124 559
402 695
99 989
590 295
540 310
115 624
903 158
915 162
832 238
382 796
860 198
620 262
815 436
494 546
162 173
853 376
731 770
444 702
337 722
995 306
839 489
464 843
761 309
562 88
27 852
192 530
19...

output:

208

result:

ok 1 number(s): "208"

Test #8:

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

input:

10000 0
8532 1309
7924 7641
3850 2342
5333 6578
4919 6615
2937 1134
7202 3833
3118 5150
3032 423
5684 647
2038 5418
7810 4255
6912 8228
6136 7472
1889 4121
9348 7211
8439 4505
9915 7800
5500 8587
4261 8149
9496 243
8502 4248
4838 3073
994 3446
5177 3384
2216 9983
3930 2243
6638 5154
1991 3731
4216 1...

output:

800

result:

ok 1 number(s): "800"

Test #9:

score: 0
Accepted
time: 46ms
memory: 17008kb

input:

100000 0
7792 26010
85804 1078
82899 25724
47158 81804
60588 36038
7704 64781
50035 14650
92695 7665
27387 75724
19543 53096
50134 64624
77873 18941
18330 34916
31993 22809
40207 54229
55324 55105
16997 96779
63858 97958
40532 31166
13028 2225
92083 90328
39005 67586
66623 36043
84284 79134
84722 35...

output:

3231

result:

ok 1 number(s): "3231"

Test #10:

score: 0
Accepted
time: 39ms
memory: 17124kb

input:

100000 0
84175 9629
86499 8316
10499 32549
6203 8049
73531 21696
59782 18131
48682 49498
84503 78323
35878 37155
72866 95140
70292 39353
65243 8130
33496 52738
74044 44275
15789 35130
55929 34691
71587 2066
14877 70981
76619 50488
89347 78338
57879 13747
47955 45641
98403 44863
90240 41682
67754 110...

output:

-1

result:

ok 1 number(s): "-1"

Test #11:

score: 0
Accepted
time: 2ms
memory: 10584kb

input:

10 0
1 7
5 7
6 9
8 2
3 1
9 10
9 2
8 4
5 9
1 7 5 4 10 8 1 6 0 4

output:

-1

result:

ok 1 number(s): "-1"

Test #12:

score: 0
Accepted
time: 3ms
memory: 9132kb

input:

2962 0
1802 1648
2780 474
20 2923
1902 2515
2650 1040
31 74
1753 392
1635 2719
2900 1286
1158 1227
1881 2316
1983 290
881 724
2904 1365
574 118
167 1726
2029 1208
2731 2451
113 2012
1763 2666
1489 145
1165 2201
2691 2141
126 2903
194 1476
2345 1025
1809 1964
1406 2362
305 1192
2007 1415
2957 1122
22...

output:

38596

result:

ok 1 number(s): "38596"

Test #13:

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

input:

58346 0
32606 33231
10774 14178
56179 20149
4402 53574
30314 6332
47840 23093
49961 30471
1558 7974
981 26443
44800 53897
7501 56273
24880 56072
21534 32688
56597 49273
29017 29780
4351 49319
29361 20740
2603 15303
57792 6137
8823 41985
25290 18398
57356 23079
15412 16730
27348 1294
28703 15186
1476...

output:

199014

result:

ok 1 number(s): "199014"

Test #14:

score: 0
Accepted
time: 3ms
memory: 9992kb

input:

11327 0
6972 5303
4106 6016
10927 1269
10358 846
8138 7882
5083 2862
1623 4163
10328 10962
6629 2486
6706 5247
155 1179
6717 9319
918 11081
7491 10594
3042 7403
1275 100
5567 10436
8364 11318
8532 4071
3070 9038
9635 4091
233 9658
1127 6631
37 5223
4314 1203
8162 8875
9962 10547
7578 9494
10083 9960...

output:

130321

result:

ok 1 number(s): "130321"

Test #15:

score: 0
Accepted
time: 2ms
memory: 10816kb

input:

2 805038099
2 1
5 9

output:

5

result:

ok 1 number(s): "5"

Test #16:

score: 0
Accepted
time: 2ms
memory: 9952kb

input:

3 734875350
3 1
2 1
7 10 6

output:

5

result:

ok 1 number(s): "5"

Test #17:

score: 0
Accepted
time: 2ms
memory: 9412kb

input:

10 32745800
10 4
3 2
3 8
2 5
1 7
10 8
7 9
10 9
6 10
29 26 23 25 28 23 24 25 27 22

output:

14

result:

ok 1 number(s): "14"

Test #18:

score: 0
Accepted
time: 2ms
memory: 8820kb

input:

100 162383393
31 34
21 51
57 12
10 23
32 95
41 92
53 30
69 1
56 14
96 88
78 19
58 54
66 27
79 17
53 87
45 47
67 8
27 91
44 37
31 81
63 46
45 67
98 31
39 38
68 23
30 29
67 81
24 12
19 71
44 15
71 81
68 45
6 97
89 1
67 3
48 98
95 3
47 4
37 51
90 14
70 55
37 96
55 26
25 80
42 83
72 7
24 82
43 61
9 69
5...

output:

67

result:

ok 1 number(s): "67"

Test #19:

score: 0
Accepted
time: 2ms
memory: 9152kb

input:

1000 400949318
343 110
979 419
316 662
283 195
334 350
892 613
343 6
644 801
394 234
651 772
921 738
425 271
102 154
818 811
97 620
390 850
460 431
535 9
839 685
884 400
882 936
228 803
670 830
762 123
848 354
441 723
703 682
350 761
595 311
357 183
326 581
139 722
646 49
611 573
909 635
947 195
687...

output:

299

result:

ok 1 number(s): "299"

Test #20:

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

input:

10000 345823004
1052 7766
9530 9030
1427 4568
8079 9988
9057 3199
1478 1945
1322 2897
886 4298
6772 2872
4758 2792
9275 3241
1365 4822
234 9912
1900 7302
534 4359
3530 6115
7067 5594
1948 9727
2263 201
5548 1883
8634 5112
9156 2164
5373 2690
5283 9117
8432 7915
8402 9694
1720 5987
4135 855
8367 3454...

output:

796

result:

ok 1 number(s): "796"

Test #21:

score: 0
Accepted
time: 43ms
memory: 17052kb

input:

100000 707231131
48773 38777
48832 96886
94005 20847
38184 84385
26610 39096
18584 87622
96709 70406
6354 93077
66183 85208
54420 35056
24557 33014
51714 40562
97634 3359
19217 50246
22794 22879
85047 61794
96031 99822
85657 28479
62933 32355
74722 13899
37385 57342
16229 67758
43018 75542
29646 630...

output:

3050

result:

ok 1 number(s): "3050"

Test #22:

score: 0
Accepted
time: 39ms
memory: 17072kb

input:

100000 624542748
54339 88265
37391 93706
49793 31645
90363 86128
70644 12453
68826 38323
67188 43865
55385 35808
88297 39728
19961 32839
57392 76128
64718 33196
93633 84549
14791 21346
23104 57259
66650 48150
24762 78150
27546 63300
58622 82239
65024 68584
99336 76052
77041 37286
16427 41240
23444 4...

output:

-1

result:

ok 1 number(s): "-1"

Test #23:

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

input:

10 688396910
3 6
4 6
10 8
5 1
1 3
7 10
9 6
2 4
8 3
9 10 3 6 0 1 4 1 1 1

output:

-1

result:

ok 1 number(s): "-1"

Test #24:

score: 0
Accepted
time: 43ms
memory: 16628kb

input:

94905 17044287
46696 58618
29838 61745
40969 61006
86351 59413
72170 46240
85305 10758
76251 23250
16930 17254
75394 51306
72582 13967
58947 379
60898 78042
7332 54569
7211 65916
59884 87581
25310 61451
48039 43366
17117 13018
46785 59516
53788 85386
42031 79010
64621 56789
80555 7462
47690 266
1867...

output:

12670

result:

ok 1 number(s): "12670"

Test #25:

score: 0
Accepted
time: 42ms
memory: 16776kb

input:

96392 594948022
3713 29055
82889 38792
73407 31742
45772 48699
10096 67518
79136 30697
37126 87462
58471 52706
13091 25571
74384 67688
29035 24182
76089 44384
34763 67458
12721 7332
40707 64640
39574 52451
47058 24829
91953 12546
4551 9908
9687 4158
86178 48472
72447 73635
90843 7135
84460 85293
928...

output:

186155

result:

ok 1 number(s): "186155"

Test #26:

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

input:

44630 66798
34786 31937
26145 29171
9291 42713
16897 14020
21823 16719
31356 11961
8813 12170
3280 40982
2337 22674
38867 9918
31569 12142
40833 10881
34125 41037
40848 17068
26515 11769
7395 21193
43981 528
11249 17590
39840 15187
31843 22097
24881 27461
6664 11744
20177 43554
36272 10372
26511 101...

output:

37630

result:

ok 1 number(s): "37630"

Test #27:

score: 0
Accepted
time: 40ms
memory: 17124kb

input:

100000 312
72197 61782
29692 1852
78657 55839
38080 83603
10595 98310
64612 33408
89865 61667
34150 13139
8132 98310
40989 40572
57778 56393
64278 64829
97557 92707
65361 59545
59900 22420
37212 1638
13003 14450
38483 50427
26929 79985
25233 68241
29785 8987
36439 37137
39513 69837
72314 25993
68987...

output:

39

result:

ok 1 number(s): "39"

Test #28:

score: 0
Accepted
time: 40ms
memory: 17016kb

input:

100000 4356
73427 41742
44108 50362
32792 43711
24797 14072
1483 91217
54866 13735
81754 73036
17039 86837
62382 5285
83953 77653
16724 242
96219 94498
11536 21322
10866 96328
6805 74352
97863 56148
3224 75334
22485 12603
18171 98091
52573 12463
30262 28643
23685 29828
1599 88497
82340 69124
89328 7...

output:

-1

result:

ok 1 number(s): "-1"

Test #29:

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

input:

10 2
8 2
10 9
7 1
10 5
5 8
3 6
1 4
4 10
5 6
8 9 6 9 2 10 10 4 1 3

output:

-1

result:

ok 1 number(s): "-1"

Test #30:

score: 0
Accepted
time: 27ms
memory: 13988kb

input:

58553 3
7394 24965
46828 40141
51224 577
37368 7467
40593 20610
47365 22593
45618 39891
33369 45790
12398 3573
27127 26261
56637 48126
1735 6875
2303 21316
2655 53770
37184 17894
39643 28809
53492 4533
46263 36015
18848 49682
17257 3323
48430 294
47135 43326
26338 13577
37938 11176
51775 21801
35155...

output:

12801

result:

ok 1 number(s): "12801"

Test #31:

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

input:

9314 4
2912 6683
1829 3447
229 2808
8548 4368
6016 6701
8589 4596
6360 3519
2536 1822
7744 4810
5361 866
4232 4469
1641 4640
34 1663
2619 9128
8844 4300
6843 8145
2687 2225
6529 5290
901 8171
5601 1162
5496 8244
5938 8364
4067 6036
2796 913
8752 4592
7214 2402
843 8015
5508 9018
2191 7220
2545 8314
...

output:

495559

result:

ok 1 number(s): "495559"

Test #32:

score: 0
Accepted
time: 37ms
memory: 15952kb

input:

82980 5
50902 76297
32356 82420
49502 4729
64583 48888
55220 81978
31255 79690
6077 65029
72362 11304
14766 68384
44786 39635
49775 21250
68775 74879
51559 48707
79153 54808
56383 58071
9373 45398
45091 12464
67790 47619
52398 14023
35522 51468
22848 74053
44739 44517
36867 71535
7138 611
15208 2300...

output:

-1

result:

ok 1 number(s): "-1"

Test #33:

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

input:

18705 6
8851 4901
2290 7096
5387 1384
9680 11996
2024 14598
17576 6742
6133 3904
14544 12897
14647 1143
16151 2998
13070 2744
10066 9245
9173 3062
14784 1895
1873 18641
14664 15978
15408 762
6448 10769
10116 10735
6527 3631
15566 15232
6018 4814
14436 16176
1349 11378
16208 11433
15648 6581
14097 18...

output:

20680

result:

ok 1 number(s): "20680"

Test #34:

score: 0
Accepted
time: 50ms
memory: 32756kb

input:

100000 0
54124 11914
47420 28744
22109 64427
43070 37969
77399 86847
17607 1501
11153 15935
49439 94615
75465 24659
68113 72991
62287 93200
40326 12433
18569 13218
26187 83372
37388 14975
22372 98963
39567 93706
24960 69049
87369 23717
5944 6604
16307 66478
61941 43419
30267 80691
50564 53426
63840 ...

output:

95626

result:

ok 1 number(s): "95626"

Test #35:

score: 0
Accepted
time: 55ms
memory: 28120kb

input:

100000 0
96499 88433
97137 68605
91882 14391
41427 49998
82158 29950
53892 22067
99722 95745
39749 15236
98237 38801
58887 52334
36271 93211
42368 29706
10916 10313
61046 56523
11556 42770
75798 25556
33181 37059
71445 52849
49781 11188
48978 92338
50918 84670
53298 88586
77113 14566
21920 18552
752...

output:

200016

result:

ok 1 number(s): "200016"

Test #36:

score: 0
Accepted
time: 42ms
memory: 32712kb

input:

100000 332105730
63780 24879
46735 72745
50684 21556
43446 46006
72472 38430
42752 25982
14894 63003
49934 24893
51432 14844
70398 24250
83161 31942
64996 31571
95010 88814
62905 40015
60158 32909
60527 75236
67158 24967
44778 77372
47814 16326
35363 62118
55447 93174
5284 25995
35602 87915
23767 45...

output:

123892

result:

ok 1 number(s): "123892"

Test #37:

score: 0
Accepted
time: 52ms
memory: 33240kb

input:

100000 393035103
5592 60987
37370 80571
67743 3480
2093 26740
13569 11415
27555 59849
40977 76164
75847 11384
4149 19357
89032 33571
69593 25848
61640 52927
95697 65463
66969 2889
78655 90438
8795 31702
15709 94402
63141 42528
82319 77357
21362 65123
57385 38377
33954 22840
94560 65153
1511 13778
64...

output:

2142

result:

ok 1 number(s): "2142"

Test #38:

score: 0
Accepted
time: 53ms
memory: 24044kb

input:

100000 94738502
65167 33749
37602 79490
49787 95001
77241 68346
28651 2547
89220 81791
44136 68753
1710 51030
92081 3575
71688 72683
82849 94063
23281 76901
5919 64438
28862 50725
136 33383
92690 93311
31835 20257
27434 3297
37998 66794
36256 23548
58404 98876
71435 43956
58060 77596
36546 69436
603...

output:

113289

result:

ok 1 number(s): "113289"

Test #39:

score: 0
Accepted
time: 36ms
memory: 31032kb

input:

100000 343532275
98391 27192
48739 36375
58027 89105
66396 93596
54674 8603
88555 92143
82771 82684
98135 99581
63213 92997
8834 78495
52458 94386
74020 76890
95732 35350
40201 56052
90695 28833
27635 53597
53947 60886
43570 57224
49601 2118
72669 6562
38817 77468
95221 98317
31970 75604
21530 74236...

output:

159306

result:

ok 1 number(s): "159306"

Test #40:

score: 0
Accepted
time: 49ms
memory: 25116kb

input:

100000 255889559
46577 71552
83347 7491
13504 52504
81103 18915
86908 68030
56335 83184
33528 76579
85354 75369
90146 82923
25386 62209
57560 22799
66917 7473
96267 21580
8833 34280
4189 92952
76229 42597
80824 9874
25929 27076
56473 55574
64844 10703
70567 98794
63350 72807
26554 53858
30728 52502
...

output:

174177

result:

ok 1 number(s): "174177"

Test #41:

score: 0
Accepted
time: 44ms
memory: 17588kb

input:

100000 209716040
12474 98495
70490 20261
12097 59540
7023 78974
60865 88562
23262 5488
31038 1046
33696 31387
79358 9615
83937 34357
25255 86147
82723 1029
35832 4471
12060 6146
18259 31531
8506 25148
53433 34652
60738 31916
70444 18474
31520 24778
44439 95427
30736 28385
22466 8846
9696 17536
13510...

output:

140322

result:

ok 1 number(s): "140322"

Test #42:

score: 0
Accepted
time: 53ms
memory: 22936kb

input:

100000 949156108
83722 2166
69725 16204
11413 32559
44956 75703
96012 82924
99319 12505
10578 53708
36723 13192
19260 31540
23033 20934
6617 98654
94278 32980
9320 10184
71442 10192
32663 55609
30656 24799
70078 19820
90105 8647
66241 12819
31777 13554
13257 16690
17579 4658
61618 75069
10281 39846
...

output:

97445

result:

ok 1 number(s): "97445"

Test #43:

score: 0
Accepted
time: 46ms
memory: 17056kb

input:

100000 1000000000
41603 29566
87807 66762
29986 56560
61236 51501
10670 71016
94042 47979
61664 73263
60226 925
94484 29649
97142 56130
94986 87300
26616 70113
70833 29256
69533 97377
3770 44195
53774 31538
21349 15960
24318 39298
84114 5767
76489 21776
72193 39280
13015 98674
19365 67006
91013 2577...

output:

168270

result:

ok 1 number(s): "168270"

Test #44:

score: 0
Accepted
time: 43ms
memory: 17148kb

input:

100000 1000000000
60435 5682
16665 22953
48594 6375
49689 14427
64145 18631
77743 91199
69190 66074
15141 95986
22460 63878
9992 72575
83375 22985
36684 24238
34826 54477
65698 85389
17024 46656
54541 80526
27353 14467
5684 55881
29307 9258
45718 23005
27200 7737
44667 26842
39384 64182
30225 85017
...

output:

170806

result:

ok 1 number(s): "170806"

Test #45:

score: 0
Accepted
time: 22ms
memory: 14028kb

input:

58279 5
28044 34533
55063 19536
35556 50705
53858 39950
58160 25213
45670 31811
27708 35578
8641 20426
35817 14697
49599 11699
7836 37102
26124 24737
24039 30744
8405 31425
55228 2607
37872 24004
55556 39191
3785 47724
42843 4423
32206 34160
19397 22020
14669 38447
44616 36836
45453 38203
11536 1366...

output:

210654

result:

ok 1 number(s): "210654"

Test #46:

score: 0
Accepted
time: 33ms
memory: 15012kb

input:

71552 6
70516 59949
52941 47640
61159 40236
46391 62775
51293 31467
63768 55773
23827 44341
29453 19253
6845 70921
42249 31419
52770 57014
7878 66812
30299 30266
20977 43859
65488 12497
4280 63531
21636 8133
2183 25727
21338 37936
9079 51589
41275 3473
26946 66254
71294 12421
26241 70418
51486 70758...

output:

191881

result:

ok 1 number(s): "191881"

Test #47:

score: 0
Accepted
time: 28ms
memory: 18292kb

input:

100000 148114306
20907 70717
70717 23173
70717 96154
62594 70717
70717 436
70717 12038
39100 70717
90119 70717
70717 11065
55198 70717
70717 36882
70717 13771
45536 70717
32146 70717
90855 70717
70717 24701
79042 70717
40660 70717
70717 85013
70717 91938
53891 70717
70717 62390
70717 75686
86323 707...

output:

241615

result:

ok 1 number(s): "241615"

Test #48:

score: 0
Accepted
time: 38ms
memory: 17772kb

input:

100000 0
90515 11764
11764 43438
23522 11764
11764 4326
11764 55284
11764 12291
73750 11764
11764 31452
64472 11764
21814 11764
11764 54621
49780 11764
11764 18086
65274 11764
11764 78454
11764 28560
74181 11764
51711 11764
11764 13462
49921 11764
11764 23390
94982 11764
93164 11764
47480 11764
2665...

output:

206849

result:

ok 1 number(s): "206849"

Test #49:

score: 0
Accepted
time: 33ms
memory: 18616kb

input:

100000 91468467
58681 28428
69155 28428
66006 28428
64854 68172
28428 81089
79700 10664
52830 68920
56007 28428
57901 78273
32136 46289
28428 96305
77671 28428
28428 12530
28428 40429
48562 12721
28428 9883
68707 28428
45821 17936
17177 16561
28428 37351
35641 28428
28428 28230
23522 28428
44342 286...

output:

201163

result:

ok 1 number(s): "201163"

Test #50:

score: 0
Accepted
time: 46ms
memory: 17276kb

input:

100000 0
44927 49849
55299 44952
2556 65819
30055 60342
6040 23953
2556 42992
58520 2556
2556 34909
2556 98234
15180 68574
2556 50934
62052 43010
30491 2556
2556 6117
92153 2556
76512 30601
2556 56801
59484 2556
65948 76582
39580 47462
11558 2556
32384 89279
89636 2556
61974 18753
97429 74948
21988 ...

output:

215113

result:

ok 1 number(s): "215113"

Test #51:

score: 0
Accepted
time: 44ms
memory: 17212kb

input:

100000 589056014
64124 2356
50236 60031
52619 40588
52619 61330
27136 5345
18171 78276
16579 18222
52619 91874
94540 14728
29032 91046
87748 71290
2777 41418
44656 52619
20574 52619
82594 52619
54449 69060
52619 95792
19441 52619
52619 62691
62294 13359
75171 30189
52619 87920
63436 52619
15125 5261...

output:

215828

result:

ok 1 number(s): "215828"

Test #52:

score: 0
Accepted
time: 44ms
memory: 16792kb

input:

100000 33528789
53043 35819
86622 60586
64505 46367
53043 31799
84994 56769
41656 66720
82172 580
39067 51704
26664 48761
24121 28842
70407 95241
76088 53043
84679 65943
19893 47713
60195 63787
71158 78076
85916 14710
50315 62152
61362 70715
31101 86296
36885 96917
63136 38378
60458 65924
13734 1805...

output:

217866

result:

ok 1 number(s): "217866"

Test #53:

score: 0
Accepted
time: 39ms
memory: 17148kb

input:

100000 1000000000
48840 84873
26911 14170
45276 77561
65574 16042
56612 43946
69001 45207
62 95767
56528 66984
57972 52381
52956 18114
86295 76308
96973 22284
65702 88421
98504 72639
73388 66914
5540 52931
83872 13783
76633 32179
25470 43281
96068 15268
72781 54618
42183 55179
98448 55268
520 96256
...

output:

999800039

result:

ok 1 number(s): "999800039"

Test #54:

score: 0
Accepted
time: 52ms
memory: 28452kb

input:

100000 1000000000
51870 83975
47280 22332
18873 11407
6032 98584
63311 83129
51633 74132
98050 38319
80672 34349
80843 74132
56666 6555
55270 51020
54248 87479
73772 3653
47377 48795
19229 77537
21245 52226
79153 87453
17440 41267
10064 881
41005 30624
16939 29778
81527 60679
69922 25401
67282 40578...

output:

999856994

result:

ok 1 number(s): "999856994"

Test #55:

score: 0
Accepted
time: 32ms
memory: 17820kb

input:

100000 1000000000
6098 12876
6098 96046
79223 6098
6098 72346
6098 16259
92073 6098
16118 6098
6098 60893
52523 6098
64333 6098
6098 17156
6098 78435
39481 6098
71822 6098
63895 6098
50485 6098
89195 6098
6098 35956
29294 6098
35171 6098
52937 6098
6098 34052
6098 96687
6098 67620
6098 39578
6098 23...

output:

999800004

result:

ok 1 number(s): "999800004"

Test #56:

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

input:

24132 291073769
10358 12781
16240 6179
16898 17324
22336 23537
994 751
4418 19911
7990 23737
18331 17915
14235 23667
21479 15371
413 1056
23527 2382
9272 975
9523 18925
20591 7805
8680 8472
12265 15214
11636 21812
10676 7438
17064 16868
1263 22370
11671 16329
12280 5831
6142 11213
5098 23790
8169 10...

output:

899992718

result:

ok 1 number(s): "899992718"

Test #57:

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

input:

31288 97569018
7749 5474
13034 6448
14533 13397
14650 15228
8330 13623
5778 13352
5949 15280
23121 6224
9574 25416
15290 11090
17513 21119
20921 15333
28477 26920
16569 26295
11937 30710
31061 24582
96 1769
24385 178
12878 5020
4720 5236
28887 28064
24361 16074
14996 8244
26989 2825
16878 21064
2386...

output:

899981563

result:

ok 1 number(s): "899981563"