QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#30174#3826. Constitutional TribunalQingyu✨AC ✓12ms6480kbC++233.5kb2022-04-25 16:47:042022-04-28 16:19:09

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.
  • [2022-04-28 16:19:09]
  • Judged
  • Verdict: AC
  • Time: 12ms
  • Memory: 6480kb
  • [2022-04-25 16:47:04]
  • Submitted

answer

#include <bits/stdc++.h>

void solve() {
	int n;
	std::cin >> n;
	std::vector<int> s(n), fa(n), c(n);
	std::vector<std::vector<int>> G(n, std::vector<int>());
	for (int i = 1; i < n; ++i) {
		std::cin >> s[i];
	}
	for (int i = 1; i < n; ++i) {
		std::cin >> fa[i];
		--fa[i];
		G[fa[i]].push_back(i);
	}
	for (int i = 1; i < n; ++i) {
		std::cin >> c[i];
	}
	auto get = [&](auto &f, int i) -> int64_t {
		if (i < f.size())
			return f[i].second;
		return 0;
	};
	auto output = [&](auto x) {
		for (auto [a, b] : x)
			printf("[%d, %d] ", a, b);
		putchar('\n');
	};
	auto merge = [&](auto &f, auto g, int64_t limit) {
		std::vector<std::pair<int64_t, int64_t>> _g;
		_g.emplace_back(1, 0);
		for (auto &p : g) {
			++p.first;
			_g.push_back(p);
		}
		g = _g;
		int pf = 0, pg = 0;
		std::vector<std::pair<int64_t, int64_t>> h;
		while (pf < f.size() || pg < g.size()) {
			int64_t cost_f = get(f, pf);
			int64_t cost_g = get(g, pg);
			if (pf != f.size() && (pg == g.size() || f[pf].first < g[pg].first)) {
				assert(pf < f.size());
				h.emplace_back(f[pf].first, cost_f + cost_g);
				++pf;
			}
			else {
				assert(pg < g.size());
				h.emplace_back(g[pg].first, cost_f + cost_g);
				++pg;
			}
		}
		int64_t remain = 0, cur = 0;
		std::vector<std::pair<int64_t, int64_t>> nf;
		for (int i = 0; i < h.size(); ++i) {
			if (h[i].second > limit) {
				remain += (h[i].first - cur) * (h[i].second - limit);
				nf.emplace_back(h[i].first, limit);
			}
			else {
				int64_t free = (h[i].first - cur) * (limit - h[i].second);
				if (remain >= free) {
					remain -= free;
					h[i].second = limit;
					nf.emplace_back(h[i].first, limit);
				}
				else {
					// k
					// k * limit + r
					int64_t k = remain / (limit - h[i].second);
					int64_t r = remain - k * (limit - h[i].second);
					assert(cur + k < h[i].first);
					assert(h[i].second + r < limit);
					nf.emplace_back(cur + k, limit);
					nf.emplace_back(cur + k + 1, h[i].second + r);
					nf.emplace_back(h[i].first, h[i].second);
					remain = 0;
				}
			}
			cur = h[i].first;
		}
		if (remain > 0) {
			int64_t k = remain / limit;
			int64_t r = remain - k * limit;
			nf.emplace_back(cur + k, limit);
			nf.emplace_back(cur + k + 1, r);
		}
		std::vector<std::pair<int64_t, int64_t>> ret;
		for (auto p : nf) {
			while (!ret.empty() && ret.back().second == p.second)
				ret.pop_back();
			if (!ret.empty() && ret.back().first == p.first)
				continue;
			ret.push_back(p);
			//if (ret.empty() || (ret.back().second != p.second && ret.back().first != p.first))
			//	ret.push_back(p);
		}
		while (!ret.empty() && ret.back().second == 0)
			ret.pop_back();
		return ret;
	};
	auto init = [&](int x, auto &vec) {
		int64_t k = s[x] / c[x];
		int64_t r = s[x] - k * c[x];
		vec.emplace_back(k, c[x]);
		vec.emplace_back(k + 1, r);
		while (!vec.empty() && vec.back().second == 0)
			vec.pop_back();
	};
	int64_t ans = 0;
	auto dfs = [&](auto &self, int x, int par) -> std::vector<std::pair<int64_t, int64_t>> {
		std::vector<std::pair<int64_t, int64_t>> vec;
		if (x) init(x, vec);
		for (int y : G[x])
			if (y != par) {
				auto fy = self(self, y, x);
				if (x) vec = merge(vec, fy, c[x]);
				else ans = std::max(ans, fy.back().first);
				
			}
		return vec;
	};
	dfs(dfs, 0, -1);
	std::cout << ans << '\n';
}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
	std::cout.tie(nullptr);
	int T;
	std::cin >> T;
	while (T--) {
		solve();
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

6
7

result:

ok 2 number(s): "6 7"

Test #2:

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

input:

1000
4
115537062 467979525 399881112
1 1 1
678922641 614994715 706841278
3
351898314 389878278
1 1
13848793 518138746
6
20898057 779849408 484145565 595498768 764378859
1 2 1 3 2
401633458 622386249 722291973 257714221 294562192
9
277053934 233703559 838134668 284395280 470905925 942205511 368404883...

output:

1
26
7
135
4
7
7
4
20
252
4
8
3
14
16
6
6
3
2
5
4
4
4
8
12
8
3
6
3
2
3
2
44
36
0
3
2
33
6
2
2
4
106
34
12
8
1
1
9
4
5
11
286
1
57
92
7
13
16
8
4
7
3
45
10
3
1
45
2
13
21
18
4
7
10
3
2475
4
18
15
3
4
4
3
4
6
12
4
32
6
3
4
1
4
3
3
3
4
2
7
4
48
1
3
6
0
60
2
4
7
3
2
3
0
6
21
13
2
2
8
0
5
4
4
4
3
1
10
3
...

result:

ok 1000 numbers

Test #3:

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

input:

1000
5
756222024 376190633 252290161 54751377
1 2 1 3
264090595 670049869 706160753 138437937
6
11575366 162382970 504213553 140951723 558132568
1 2 1 3 4
726496665 350044718 612887738 905031567 657407877
8
854598977 934973045 691658082 880332766 689230810 317546689 401480125
1 1 1 4 4 3 6
975963204...

output:

5
3
9
14
4
5
0
4
12
14
4
3
12
3
2
5
3
9
166
0
3
16
3
5
6
1
2
5
13
194
2
2
1
4
8
40
6
2
2
3
5
8
3
8
5
24
2
66
8
8
42
2
387
5
2
120
3
5
19
19
4
3
2
11
8
3
38
9
28
7
30
3
7
1
21
6
25
17
0
28
3
1
2
44
11
2
3
120
44
103
5
3
5
2
1753
8
12
4
3
0
2
9
2
7
624
10
2
265
1
3
5
2
15
3
2
7
4
7
47
7
5
2
7
1
11
16
...

result:

ok 1000 numbers

Test #4:

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

input:

1000
5
257180491 517420781 700052737 396312842
1 1 3 1
865085945 390525919 831290338 33127229
4
637686640 829140908 101182720
1 2 3
890179 529961481 986224995
4
427134462 980072562 583671857
1 2 3
498866532 673011802 178006285
6
683186647 99174292 419115778 201737728 193652354
1 2 3 2 5
828448852 61...

output:

12
1762
6
7
3
0
4
2
19
15
7
13
24
18
2
2
2
3
18
14
126
3
19
1
9
31
3
56
4
5
6
10
13
6
4
4
19
3
12
4
4
2
2
5
3
25
0
24
3
8
3
1
35
145
5
44
5
6
1
3
4
2
3
10
13
10
2
4
6
5
3
3
2
2
4
0
2
5
3
20
6
10
3
114
19
167
3
15
9
3
29
22
2
4
6
53
5
4
5
9
233
9
4
2
1
8
27
2
9
0
4
3
5
64
1
2
2
5
7
14
53
4
14
10
4
36...

result:

ok 1000 numbers

Test #5:

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

input:

1000
5
481198825 749785468 637738695 741242679
1 2 1 4
127180747 493603793 578458338 507534243
4
733870926 386536977 410131990
1 2 3
500100724 440532780 286743983
6
432614431 329631796 23076908 634981639 835042091
1 2 2 3 4
205041278 573285174 584567001 554895405 59168468
14
678616254 703985499 6264...

output:

10
4
17
27
2
3
9
34
2
5
16
3
4
20
5
37
6
1
3
1
4
52
73
8
6
12
5
3
4
1
88
3
1
4
8
8
18
5
4
6
1
6
7
2
5
35
31
16
4
3
3
3
3
2
4
22
12
11
45
64
6
5
9
3
299
13
5
272
4
10
5
3
13
6
6
8
14
6
8
26
7
4
0
42
2
3
6
2
2
2
30
9
3
16
36
2
6
73
6
24
3
57
11
15
5
3
4
56
3
28
7
5
5
120
4
5
4
14
7
1
5
3
3
6
10
7
9
2
...

result:

ok 1000 numbers

Test #6:

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

input:

1000
5
598362212 280978188 947009985 721619189
1 1 2 2
712139443 773515119 182336788 638222984
7
157710011 208565576 25868116 405773362 891373952 791625427
1 1 2 4 2 2
255771483 916438311 81304939 802967407 29301172 417036945
6
747432327 644711200 563416266 591809683 488768086
1 2 3 1 2
358148124 77...

output:

7
32
7
14
6
1
14
6
1
6
6
9
4
4
195
61
5
3
8
6
9
14
22
3
6
3
212
4
4
5
8
9
5
6
11
0
2
4
2
18
17
2
13
6
7
5
52
8
59
7
0
2
7
42
11
5
4
46
3
22
5
13
2
7
3
14
12
19
4
6
2
42
6
12
9
4
8
7
0
2
6
5
9
27
29
3
22
5
3
3
97
1
8
0
3
4
4
7
98
10
32
1
59
7
5
3
22
10
3
7
8
3
29
101
15
6
4
6
1
10
1
2
6
15
3
25
2
4
3...

result:

ok 1000 numbers

Test #7:

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

input:

1000
3
627048031 749814867
1 1
902908562 951655928
7
837337582 741895612 884872347 467556481 141443623 41215976
1 1 1 2 1 3
685982084 685714964 365050431 526790305 611581603 303991246
5
822351294 532234133 764694889 979814376
1 1 3 3
716257998 255057859 708899284 117872314
3
629840855 935366283
1 1
...

output:

1
3
10
4
162
3
17
6
4
5
2
12
3
6
3
10
5
6
7
2
1
4
6
35
19
6
4
1
11
3
2
5
1
20
15
2
3
9
61
6
3
34
4
6
6
26
4
2
4
3
2
4
36
4
2
2
4
5
4
18
6
9
8
9
13
9
57
21
2
2
40
3
5
5
5
3
8
205
2
7
23
13
8
4
24
10
11
3
11
9
33
187
4
1
8
4
3
3
10
17
111
11
3
12
17
5
25
5
1
8
8
4
4
6
10
3
19
1
12
522
4
12
8
1
3
20
10...

result:

ok 1000 numbers

Test #8:

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

input:

1000
2
16639933
1
62
4
589586612 418283501 893929992
1 1 3
51 80 14
5
238394260 828306885 987915358 564839796
1 2 3 2
33 95 31 18
2
251444738
1
15
5
657261597 887981786 424591362 619743450
1 2 1 3
68 52 3 75
5
695812533 546072485 843333016 988796813
1 2 3 2
43 98 43 12
5
64663050 165770316 318406778...

output:

268387
63852144
79377464
16762983
141530454
82399736
9097338
76565268
227999356
39479351
55301438
32587967
60588147
93516881
29692039
30425056
193141913
383706296
16482428
37864117
287927168
24541600
31544155
18529514
80657916
69460218
58470434
54769929
14208092
41989461
92623979
111706851
15404427
...

result:

ok 1000 numbers

Test #9:

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

input:

1000
4
5606016 99214696 710013319
1 2 3
95 89 85
5
775457833 206895474 556586555 750516965
1 2 3 1
81 33 5 28
8
407994616 79803411 869287533 995147193 232982575 309701051 865267580
1 1 2 3 4 2 1
34 35 61 16 78 57 41
3
938074382 672535012
1 1
96 31
5
525970568 587411957 830933429 422821110
1 1 1 4
99...

output:

9092451
111317313
62196701
21694678
13777523
12242731
67425468
22227875
47905096
43446818
49992234
139825550
123504331
31033691
14055803
34829681
109762039
240620560
69866338
31543448
0
28095382
295498801
3969882
52610802
36741307
9677899
108020579
307958699
28956681
124689155
41544634
129768659
0
2...

result:

ok 1000 numbers

Test #10:

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

input:

1000
6
704827483 928494366 940749037 613855968 21395855
1 2 3 4 3
96 20 60 43 4
4
193445492 382318115 177805632
1 2 3
50 38 14
4
635775814 249441580 653080853
1 2 3
14 30 10
4
278693285 902509050 78192227
1 2 2
11 72 11
5
431790208 3899856 303790909 225575681
1 1 2 4
23 75 78 56
5
585455728 43289845...

output:

125224763
15071385
109878447
114490415
41789426
100050483
8694022
97930836
1458414025
20499423
138255952
14234569
100189352
79240165
43304609
147409985
35603906
97061102
85069006
25934038
67011642
5285920
34266242
0
19343024
32621171
257619370
92017719
44387092
7497666
16438401
123773634
170326000
1...

result:

ok 1000 numbers

Test #11:

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

input:

1000
5
545506068 704056464 294590098 1499571
1 2 2 2
18 36 10 54
3
479711560 134248093
1 1
52 82
6
741490769 720925550 155641476 733399768 395246156
1 2 2 4 3
85 80 79 8 63
1



5
661413063 799485689 204095089 809192690
1 1 3 3
27 63 46 51
5
852385993 764072110 972871449 910296246
1 1 3 2
83 78 37 3...

output:

85869567
9225223
91674973
0
28774183
303432083
61402087
22223307
22726681
175607573
74667788
19804538
9400450
19752316
45708781
13371219
150425875
32603776
777692823
23313406
640197772
35321439
16382962
73497481
4217254
230228827
26402679
1633549840
30893806
7219854
17972881
29111523
16583582
214309...

result:

ok 1000 numbers

Test #12:

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

input:

1000
3
386976616 109795179
1 1
9 48
4
662975950 674012686 372301104
1 2 2
79 94 30
3
706969835 562160622
1 1
93 53
6
968451944 631562737 396632484 42872968 470515264
1 1 3 2 4
46 56 93 98 92
5
915162553 328511811 905956033 359042583
1 1 2 2
99 97 98 12
7
933411395 147996352 511313784 686389881 95484...

output:

42997402
21636579
10606805
26762688
29920217
96049900
99883467
38449772
45127306
121172929
407338548
54817661
18754750
60240090
66662217
165191133
66705998
7861024
9932739
462841080
62046938
182531078
351232203
3625014
45076443
30622183
39961476
78660823
313026784
52659123
45622687
6280842
10637506
...

result:

ok 1000 numbers

Test #13:

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

input:

1000
6
462887010 344275993 830561895 276297266 458851284
1 2 3 4 5
33 45 86 19 71
4
426501737 74871365 293938180
1 2 3
28 47 59
7
226119338 696798711 311705825 20913963 636623538 752766733
1 2 3 4 5 6
10 87 61 30 90 84
4
926031291 575168556 480440594
1 2 3
92 22 78
4
851387369 39197792 700359076
1 2...

output:

71905256
28403975
264492811
47982236
75759250
69159413
67999713
331138104
75114626
76243570
147134070
491363784
336794735
87210445
992915128
91593815
232257454
23057374
2047415276
273675509
54739107
31725439
179868702
144504259
67722181
1475032429
30711660
305148830
13027317
53990027
11347505
114329...

result:

ok 1000 numbers

Test #14:

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

input:

100
43
502690318 89463996 480398176 148727666 119853092 582319830 365463288 245520000 769936941 507308396 680990137 64741531 578579292 193745608 471812669 338416220 864232317 305569934 627246154 26409719 244161380 359217532 334919764 119497754 731076221 410729503 937009074 931058761 254784427 130870...

output:

4539039532
21852393021
7416647443
7929870819
6035054030
4936617591
9182030755
8045863476
4573825013
12515150080
6807482465
2200859495
28680383414
6679933551
2218969327
4895476295
1819000584
17984966929
14982127436
10618447360
6574171715
23375097850
3211593019
11341314105
3030314517
11077380104
50309...

result:

ok 100 numbers

Test #15:

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

input:

100
41
280496739 580807427 853676623 877974011 146278057 77980586 244658551 502820085 162558743 400909885 489543200 706497692 379974754 302840559 786988827 563739320 985149076 584162361 552439593 269104858 852056037 723177164 440008057 524394455 811176076 418747931 33979297 159177507 129505820 77795...

output:

17842126520
5813048634
6963814781
18666674226
19287485881
16776010969
17580776170
24552310308
5421383453
4463561049
9563783758
25437143785
2029670274
9914229719
1529789815
2834662213
24540855795
5403886381
3336991837
7607574006
27603403289
3558914402
19349173867
1349150097
19309020578
3743859492
117...

result:

ok 100 numbers

Test #16:

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

input:

20
251
103028374 26498092 626615975 766949652 637149306 597974729 339394173 993524330 861449078 605181366 68307693 538526938 444085547 4190917 628501476 864607653 811095800 476240419 643781257 532403648 495828589 1478646 952605380 807572710 695647876 757721453 731344554 554320542 528688370 949472507...

output:

6952044469
5586199113
39860564972
77072232280
19480518390
15706188058
49447905423
6512959369
19421100866
8939373979
3894428290
3919430781
32873550231
10625657056
5942905993
27112844705
7671570042
13608615774
44164974499
45001861458

result:

ok 20 numbers

Test #17:

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

input:

20
276
671706220 418501431 761732996 263359598 866134597 358254987 206837762 508519677 253998990 40681571 754615749 963924510 139073736 296801968 393113766 197166273 232200317 905512842 390058048 952443159 35578587 924385178 132437345 570396775 805969129 179427862 915361760 829292427 917517562 84270...

output:

5344595621
13817710278
6205338126
14034721752
24059825718
6013904067
6744717964
6706216676
2525289859
11880377315
112249565703
131519689811
13073289643
3953948155
25779132071
15138012277
27397423296
6899752787
4758127585
5441753683

result:

ok 20 numbers

Test #18:

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

input:

20
242
670971802 665399711 45772 388712574 383478052 526019519 879143597 455841082 15362645 241093571 782212700 155129143 944627940 716650359 64324112 23727838 116605293 888716049 39968440 148308987 496943244 3715392 438897304 491011901 837442771 470351606 747414055 86043063 820499289 51520468 36002...

output:

35468917794
11901078862
19123799607
14305562503
59548930892
21656016187
17507329213
41084090219
28919648553
30050694963
58830420175
10194041420
108796298233
42567642293
13339156262
12258364080
27672315906
120029310671
9930301354
45605633484

result:

ok 20 numbers

Test #19:

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

input:

20
247
23804961 753518531 891726164 359829547 129665343 804667799 277742698 532220052 49026057 449985356 611777895 843583978 638477626 811630106 120348703 792703846 961332090 65953766 41748889 426469466 244495627 946564276 910827513 843797477 576401670 233853529 743949306 319109845 597647963 7624143...

output:

116527441570
60339297770
122040369133
133143849896
81798961558
122162049287
56882631114
134865868867
124360760060
53477371984
106003280580
135469080123
104605452023
129313426945
117881779618
112612808859
59017462631
116294361418
116697762594
123538271580

result:

ok 20 numbers

Test #20:

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

input:

10
465
765705779 393860170 476856403 949944635 244827337 970042248 529242887 231120787 600443482 172070023 635415525 594356285 558637381 66797170 679432693 175260882 964848431 487721981 553678570 943550014 991208132 972687021 630780381 908294582 324281220 374916051 329785437 145014541 835027244 2435...

output:

8990
981087
28160
49721
332238
6750
11469
16251
10794
7478

result:

ok 10 numbers

Test #21:

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

input:

10
530
696269578 407743427 199408693 111110739 972785850 308282252 31853377 189931997 242129288 238676914 152922510 654339764 57389481 998088067 487717313 651832089 741440671 426141022 580275201 322230073 202292243 648428397 539395438 660709856 168053788 64520746 733375899 952987325 459416365 325291...

output:

9688
2347
10890
4399
18618
3040
34146
16554
36055
60095

result:

ok 10 numbers

Test #22:

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

input:

10
510
655977266 41827066 662521511 270407086 452696662 284122809 851995489 181864953 959703261 970696341 938397242 396700432 555624004 256964297 678005212 92390598 347162940 433065893 659647576 247651718 445791043 252086208 888325294 69017244 750370633 327228914 434099578 782672328 713229404 846065...

output:

13462
5282
6427
5381323
12571
7066
2317
13989
17708
6311

result:

ok 10 numbers

Test #23:

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

input:

10
477
332193674 315145986 853202971 430532626 422257746 611069497 403803052 583372336 847245730 962008682 258274858 853803505 558850807 109293422 147879621 884767380 539077463 351025322 995403352 782443868 642950727 521354532 183035720 783801713 224776083 883404036 496822678 501420167 230848595 473...

output:

41831
52014
250720
4400
3296
11127
93974
12376
110104
11224

result:

ok 10 numbers

Test #24:

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

input:

10
499
239367224 730469409 807066099 651717585 533582767 655678558 179913952 856591840 257731770 437439122 852927911 847536059 913291224 73969233 161088934 573539677 75422638 209696599 158247201 303428729 348851899 738513372 468194894 702352386 755984253 260752587 32384366 106936072 385812577 722662...

output:

3458
1772
843
1720
1857
2634
1253
2275
2528
8992

result:

ok 10 numbers

Test #25:

score: 0
Accepted
time: 1ms
memory: 3700kb

input:

10
468
565184414 382391491 54219520 509779711 417858888 141562098 100285377 778285423 142699602 605685974 332401120 980763941 4122371 710751265 635262626 18560138 37455530 866511200 776117763 544110139 669203390 507766496 936225871 385692859 755463842 87091633 702838675 402914903 144818760 102780121...

output:

259907
4157
4806
19446
5908
8678
16855
1738
4848
8221

result:

ok 10 numbers

Test #26:

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

input:

10
569
159242951 140430873 166221548 455349391 601920960 785624479 414450633 199791745 52964820 307641984 965497721 218328583 446226922 617981874 590800586 986340557 605262056 780569604 621062495 802175688 605325729 249852950 446068053 415110415 79271148 770993056 224859486 837630217 293486347 13863...

output:

268043461320
227915674591
86551647168
239316730616
231459576088
31913936920
235789627417
51565024548
238637824718
66379088841

result:

ok 10 numbers

Test #27:

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

input:

10
478
721756041 340012112 14333098 43514017 313038637 811188898 458592435 760929858 606221400 569172687 646825676 776795898 78163632 792421418 26711812 75657561 958461108 481422707 4647183 91865573 865253213 35269910 91803305 339673992 291700351 326568210 846990903 175757026 494218606 425020698 359...

output:

240069485628
43231978038
254157413957
114534828251
224098891706
78546408720
241447434994
63248491042
136934516581
35448802739

result:

ok 10 numbers

Test #28:

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

input:

3
1643
842595898 256955459 81711502 535367753 485991865 693404826 293670181 774047554 881473578 652826233 742879325 553796285 548475519 125184550 598472260 275665470 822368630 345630530 855852227 924033348 397606215 731906231 4377848 664634856 808938960 37828885 406503586 576511814 368868730 6065589...

output:

725118296461
231610846967
330587642842

result:

ok 3 number(s): "725118296461 231610846967 330587642842"

Test #29:

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

input:

3
1678
907348296 859979980 70266743 888460740 769396711 71601840 933182633 817749045 3244257 765948393 262285732 218951149 198087755 640596972 753662123 412947484 74126095 922399200 501490158 629474209 942607043 477952312 93201907 9181291 844478953 658205021 371823250 579780414 609022605 438755612 7...

output:

583821471225
456817464307
733316350444

result:

ok 3 number(s): "583821471225 456817464307 733316350444"

Test #30:

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

input:

3
1679
915024208 745278436 201334330 407274032 502960592 713284029 188570079 146430459 28097559 583294529 839546322 736541205 898563288 284623355 578126247 478595630 325469493 606193942 837026192 249175873 795524484 79696007 91618866 612294388 237302188 404449512 541249644 998702809 269854671 216073...

output:

375876994795
417731497781
793664807366

result:

ok 3 number(s): "375876994795 417731497781 793664807366"

Test #31:

score: 0
Accepted
time: 1ms
memory: 3620kb

input:

3
1640
68854836 517419785 116050343 762954587 471087044 692030413 313934935 187366371 776155564 876627743 241941709 83054293 666227240 460242000 853357478 170530251 403186986 510540496 107006728 631917081 908096731 570144375 867629068 273719775 574294481 864565199 186408755 643620228 71015999 328229...

output:

403065603611
655260522196
367675076462

result:

ok 3 number(s): "403065603611 655260522196 367675076462"

Test #32:

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

input:

3
1734
913941334 71262103 912358350 22174254 79359952 45116877 466563951 218346478 982541531 432048340 269134715 16933899 632912424 855891681 751427859 141618364 15450806 746864528 460426465 818884960 50557731 943693282 856048593 202360522 784765398 700564256 239314383 10190804 247042599 386216338 4...

output:

189902396933
166496411305
178322220584

result:

ok 3 number(s): "189902396933 166496411305 178322220584"

Test #33:

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

input:

3
1690
684013608 728409203 621823878 13568056 274060089 922524488 950606131 805026985 676005299 182059751 287257990 664513672 534819787 871029179 307847690 633745803 230443734 908525108 386733078 464331981 252316404 595918838 424381321 451094191 56661410 90732954 593861460 161673202 180716303 254394...

output:

216489728062
200012851166
597950284597

result:

ok 3 number(s): "216489728062 200012851166 597950284597"

Test #34:

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

input:

3
1615
495807261 512419601 508245890 360482118 788932549 559699300 959867813 95473130 484465602 722034781 755467354 237320821 474409683 192614876 542861651 156157463 702032084 397110473 871301631 234711187 441759310 654793439 894974217 931137099 26969171 709353451 116253811 313145147 276045241 84663...

output:

573793477390
291896300388
357741244012

result:

ok 3 number(s): "573793477390 291896300388 357741244012"

Test #35:

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

input:

3
1665
200124491 22738626 833404536 884534435 817201832 739269935 932934032 561669440 563630750 362210481 202236980 664417332 423686990 383361228 318048237 279521576 817213389 94288687 127493395 172619692 903051579 16166507 996922122 499760386 238353003 235390550 952162767 41574769 432171902 9878697...

output:

825446851227
238996452592
204571604226

result:

ok 3 number(s): "825446851227 238996452592 204571604226"

Test #36:

score: 0
Accepted
time: 1ms
memory: 3736kb

input:

3
1690
93484565 712569717 625552129 326659683 876702937 653878014 100230417 436099398 869597337 103962328 278898343 765964154 75538624 489542376 516846407 609329061 555757109 47068461 566299908 971616059 907142429 362194573 421765959 12063097 635965393 533889986 664329922 538057851 715994381 4105824...

output:

51069
209280
81491

result:

ok 3 number(s): "51069 209280 81491"

Test #37:

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

input:

3
1689
57803196 569228379 453443991 550303044 397161623 959345046 743734723 744978885 732687077 79763375 581132030 505538568 547623651 748144187 35213573 327028819 711400144 556848445 290102228 506155856 231675282 74241791 314705074 19685839 413844947 26413803 39151200 814346950 827025881 915246751 ...

output:

29572
372811
42485

result:

ok 3 number(s): "29572 372811 42485"

Test #38:

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

input:

3
1604
235199979 87430874 496535671 27176291 729749620 983488180 639596073 753280060 237484134 433705675 958688665 264652615 864712413 703267386 64099736 655004898 893788757 19994765 452547465 982022817 286062954 582493034 722703958 600491941 361103403 353955632 905138230 458050698 547663062 5945458...

output:

63839
115027
195166

result:

ok 3 number(s): "63839 115027 195166"

Test #39:

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

input:

3
1625
39323583 77092133 703620616 560435799 590467725 553142877 377224657 520059497 599565948 372963949 985982016 898907874 668553513 116376516 129085626 730958279 552911652 744611799 691826317 665474083 828428387 85889235 52147795 31964370 451940926 787669847 584548370 249257514 483790391 75271510...

output:

40013
44101
170220

result:

ok 3 number(s): "40013 44101 170220"

Test #40:

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

input:

3
1728
340719449 949598638 549414014 151226921 779902191 134079839 958199850 108011386 774769265 248178030 667866670 449281155 475865939 439039889 482579458 897024970 120210579 677610283 444006659 627993200 651654193 897309178 799197688 765449531 727030509 579368493 891171366 3956111 580042515 93461...

output:

216064
648901
20439

result:

ok 3 number(s): "216064 648901 20439"

Test #41:

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

input:

3
1608
914085698 517610520 335821093 678223428 484647863 248041479 671596572 35245733 751312051 137555062 978316504 91471519 451247566 444514408 369017185 868946867 436253614 889891401 672751803 831059658 782947887 192926576 37625324 783597196 703445637 120503593 747441456 661810275 807686244 984281...

output:

69411
1047822
61657

result:

ok 3 number(s): "69411 1047822 61657"

Test #42:

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

input:

3
1671
465617878 128962385 258765106 793463244 991411210 808924396 688634145 364394485 168150245 857416026 101750449 761909844 558296358 928826520 620085894 650888669 623553641 25900113 79350587 716463443 734380742 45118171 564540827 370658379 416984294 374020958 801796448 437432362 563401879 828050...

output:

24907
301287
55402

result:

ok 3 number(s): "24907 301287 55402"

Test #43:

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

input:

3
1651
35952990 838244294 59460756 937205470 877913657 27414096 655781824 891676953 640296040 832541395 769698118 294082855 480792312 408336623 548234128 27373439 248295577 180521642 718302054 589404160 806864678 734698431 53423632 850989425 655371607 748714136 800084460 541341180 681504761 28285846...

output:

145674
32615
47185

result:

ok 3 number(s): "145674 32615 47185"

Test #44:

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

input:

3
1646
710359414 346633224 756379351 932842479 638524542 812589130 518214365 539766014 873630270 933374099 109022774 501893226 586624719 487665233 913609973 964744664 531204948 701535076 204855896 230241746 156545077 897432211 777864822 117549418 230915292 49350474 889873101 88460785 698755800 20750...

output:

44390
61437
305136

result:

ok 3 number(s): "44390 61437 305136"

Test #45:

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

input:

3
1622
35336716 586216217 669875823 28924038 144684032 248374482 752035419 623367092 773810590 31092604 256068187 396880063 712319949 202914240 268184912 695733889 904932026 47495520 811271926 760496779 658472411 165646137 790599764 235716439 705661650 783677696 680120703 942735426 445321694 2302883...

output:

786079103489
828341225174
856405036986

result:

ok 3 number(s): "786079103489 828341225174 856405036986"

Test #46:

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

input:

3
1658
105394966 213563852 148793553 361188778 555550859 106727778 28014489 855913804 258940177 454980420 168244831 828625788 499039357 505432114 363737846 292448026 913039002 631226702 709153897 195857399 747062712 502441624 532293121 938204869 255741124 839696381 376291272 279099258 640350271 2487...

output:

797105694157
833423375976
851931607553

result:

ok 3 number(s): "797105694157 833423375976 851931607553"

Test #47:

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

input:

3
1724
247731835 523954422 736756160 257340543 230406084 310029480 535188771 836238028 677141000 362744815 500251902 332323104 14043248 406228518 540552432 187664561 948678181 628763451 737862588 956906627 373184207 347763984 168638914 484568290 9391885 318610330 956806789 531929030 804019565 827463...

output:

846492688790
821470711533
808870740172

result:

ok 3 number(s): "846492688790 821470711533 808870740172"

Test #48:

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

input:

1
5000
96870832 858016465 65553281 503638772 529433901 81437485 138591045 315903015 984523456 297001182 661571482 200267357 940708226 410634321 916309548 390820448 815408704 88932018 376497095 485666547 408370932 453948827 591630186 921144690 107100409 185374919 729754165 408020062 254400426 9155712...

output:

2485456702532

result:

ok 1 number(s): "2485456702532"

Test #49:

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

input:

1
5000
199518753 759316648 157709232 68974912 180261622 983288117 351370782 216055902 917614729 177609033 797151068 269649149 727146456 905443503 368118366 777411566 300136473 746046541 719879351 73438361 992174226 433142905 183065030 87470570 107389876 475757713 126392712 627161403 931375371 424984...

output:

2522568702120

result:

ok 1 number(s): "2522568702120"

Test #50:

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

input:

1
5000
419307902 32492993 814671245 189389133 624376201 120912693 948374419 396531438 459513003 293963906 935933661 427010604 889890562 150629972 500060376 641069912 802066911 839268908 289608477 849930801 152895797 316474801 56790443 862891607 767854681 222454441 171398397 934857591 349491278 83462...

output:

2483534466602

result:

ok 1 number(s): "2483534466602"

Test #51:

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

input:

1
5000
280074275 856636077 387162007 72738277 250239075 695986491 657405066 910403523 64025104 96621780 606111978 611413475 178603261 60977064 962244231 125068858 407690153 765484353 773290894 782945642 639894355 949033510 783279586 882225906 251653810 375042519 899632850 452967873 153660859 6318619...

output:

2494212969147

result:

ok 1 number(s): "2494212969147"

Test #52:

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

input:

1
5000
630014664 1634679 51316562 747711434 531023998 944531943 492452507 635542633 869240032 724983149 832862552 363336189 172870145 584828714 992231564 857358312 718530739 102188797 984223820 813286823 30510452 568966948 951338532 993625222 47530906 172107110 7436514 200154396 392346596 450643222 ...

output:

2461932137028

result:

ok 1 number(s): "2461932137028"

Test #53:

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

input:

1
5000
714505943 712491626 826956565 553401677 77767938 67076700 250002140 246218318 634794934 442577736 556492479 785669804 822979474 506994325 526854296 499316136 229331905 898350917 108424256 883588748 570434968 774420887 415822980 72170492 374345868 733363503 279010965 6807688 461124740 37656726...

output:

2504798991687

result:

ok 1 number(s): "2504798991687"

Test #54:

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

input:

1
5000
794042087 194750347 325387084 324398221 163469930 546763120 31433248 690440122 991350168 992126940 555247267 644557385 81632401 737962912 919431857 512425745 178822491 851991305 888198571 525358687 324219231 746931482 435767178 734098356 678643837 405050306 89919564 186347499 902511097 117723...

output:

2524667768713

result:

ok 1 number(s): "2524667768713"

Test #55:

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

input:

1
5000
429715758 127237671 279194680 619211325 187017843 829924356 337988933 861744893 663597589 280228328 20068979 102271341 300905409 750356918 286217735 765748947 121262724 395060044 346797593 495093062 789667729 589681203 118891272 80877791 863486425 718044546 850636409 258601982 871823270 25133...

output:

2479222032159

result:

ok 1 number(s): "2479222032159"

Test #56:

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

input:

1
5000
559405556 830294932 885654118 268934579 18518464 286704686 421355621 714781389 578951388 705593951 958611499 130824657 70291793 172556076 627034667 447229421 96549699 626936071 263579568 290301951 637883713 906002890 309101575 693522979 210857618 719107758 991968990 747613768 636283594 137831...

output:

2512578653470

result:

ok 1 number(s): "2512578653470"

Test #57:

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

input:

1
5000
183319274 359058985 412119184 348451067 710623890 411201579 369489610 501801208 849199127 165709420 840394837 900399901 464814163 85756215 508164231 587444945 277279295 615779643 590845770 975851121 314939470 942664622 815270426 835363176 384181743 22298986 428884626 814608557 177914675 42871...

output:

2495939767816

result:

ok 1 number(s): "2495939767816"

Test #58:

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

input:

1
5000
468520553 708362214 1396506 461629649 551779470 345677486 447630490 745603055 836984914 705753338 656656929 90843312 370692501 500934750 774164213 569963196 201275365 270102184 27577401 965187028 718634152 308149884 627590191 648045183 63903186 950055622 585128453 937406190 552194256 15327256...

output:

36522

result:

ok 1 number(s): "36522"

Test #59:

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

input:

1
5000
599278719 518670167 403329497 885844164 800768091 621037098 893466948 240554639 89100268 741117404 189001355 239263475 924934220 601496751 826096752 425679542 270759381 197022228 421028542 807983219 485358161 244384551 193141741 605733791 412938642 885313841 702659467 203448730 422329627 4610...

output:

57755

result:

ok 1 number(s): "57755"

Test #60:

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

input:

1
5000
659300576 915010058 56273356 200000124 107842123 555169687 831230267 352447500 254501444 596967657 993093085 29155304 662640360 307468839 895757735 69606352 337280787 629831621 463971668 676011004 279006729 290703758 84177840 576281945 818394843 828111707 960065549 469113526 166488715 8412064...

output:

29245

result:

ok 1 number(s): "29245"

Test #61:

score: 0
Accepted
time: 1ms
memory: 3944kb

input:

1
5000
574909654 459836894 401228940 110089682 500226744 133619578 682720734 684899621 462665664 144766141 614591567 237192535 400249981 452537041 43312909 871918600 939410814 522779459 298765707 846941855 401057208 154812091 445051264 668495696 657049548 407234347 382529651 684439479 93281552 90033...

output:

18022

result:

ok 1 number(s): "18022"

Test #62:

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

input:

1
5000
308933431 189073570 66674357 344454869 9090056 914805369 808448702 920409992 134791896 232254728 620754226 593593753 993489325 701104014 440243643 554387717 265761151 96663190 638102569 454562104 80643585 70574006 938527314 797339624 682168898 22685422 868953556 879948008 776036623 197886022 ...

output:

55874

result:

ok 1 number(s): "55874"

Test #63:

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

input:

1
5000
58613321 393522998 547011994 161794006 455290786 32613970 940025023 793425569 808464077 465615158 937796123 747201499 4274278 768622534 546631084 904754188 540168248 971815994 421587098 637362737 906857415 328296126 472100330 144447978 423466063 173644538 150617424 627659610 970803172 9783552...

output:

91433

result:

ok 1 number(s): "91433"

Test #64:

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

input:

1
5000
392701989 749296822 937192018 311255519 758730157 525317976 440074004 955010726 233402879 3744917 749729257 15176448 41727979 777881771 219555774 535452207 878946692 285886242 831555347 650547543 635705756 893741916 573342729 161096685 729107604 43692122 851780703 842602792 160866211 53396375...

output:

20605

result:

ok 1 number(s): "20605"

Test #65:

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

input:

1
5000
172055156 374019896 919705913 786482292 550854206 342980100 608060870 399377501 116124146 641373112 88328358 689067537 38815268 169805713 537446181 138151396 420471793 57619009 438496384 957644962 236070679 906673805 107851852 593024870 390328525 284550458 101153256 809764877 951450592 570837...

output:

50918

result:

ok 1 number(s): "50918"

Test #66:

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

input:

1
5000
730969705 593282054 669320647 430538970 397194293 768998694 517871057 532171710 502342640 12957740 626096472 494463052 546219590 785677276 550756374 321370897 267247474 656904671 189424544 82299798 332522827 830107290 108779267 221095532 512544962 438222660 337194226 108543470 979627499 11025...

output:

12905

result:

ok 1 number(s): "12905"

Test #67:

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

input:

1
5000
737773916 596822867 366878615 882760357 645289292 595544971 121240625 121099057 206360498 634429304 180546858 840000691 857635550 646030782 148264093 416205322 769254061 521922580 203344692 542041494 946061176 205422177 114702690 97121468 72884614 737062294 993310047 868851252 478525535 47635...

output:

55666

result:

ok 1 number(s): "55666"

Test #68:

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

input:

1
5000
40818948 334457986 167628303 609638250 847729402 135400742 257439447 885979809 749134832 187064514 891313361 474960456 498096343 874870460 189422015 737648197 184741406 113856583 362014008 296144176 820102980 631823231 298867602 856151919 239463570 952128457 65367553 487744738 151348151 96467...

output:

18398

result:

ok 1 number(s): "18398"

Test #69:

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

input:

1
5000
335686199 443246661 93356406 734857627 670459540 293479253 119835267 618438300 814388174 683120473 948355872 933813286 356815435 583359227 874941254 308476288 863367240 130637193 52742015 649233662 151531741 692202683 287861767 307037136 880994605 631467825 252370256 722666509 360918465 38857...

output:

57454

result:

ok 1 number(s): "57454"

Test #70:

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

input:

1
5000
236849120 229661102 125212742 869703034 137169758 577474122 917583109 97245441 267084830 977017730 768393751 473748980 894988954 417872392 991089143 107680829 617574261 823372514 794313426 44058521 904190661 772832111 128061243 599095753 698963568 926675416 566360884 14501347 415172457 422011...

output:

37919

result:

ok 1 number(s): "37919"

Test #71:

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

input:

1
5000
940645959 748663334 933377109 239639897 460620732 212910260 385096334 597470903 492835466 691622948 921109952 694503374 114143180 100511469 78030164 37934057 225549645 21957390 727802165 465695270 46285373 33977932 154087677 338419706 213975283 203172933 772319701 67895344 89608379 262064013 ...

output:

52459

result:

ok 1 number(s): "52459"

Test #72:

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

input:

1
5000
335282037 466171549 270312428 73954346 327658959 763741798 684368117 162433603 885184231 217505319 415336368 356586364 250694463 95083799 705026009 851343706 660174974 59056391 412418177 193190665 307710600 910051094 635855138 589223430 366320949 336030052 981916269 221363346 107407579 252230...

output:

6767

result:

ok 1 number(s): "6767"

Test #73:

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

input:

1
5000
375663269 261128425 110424638 642112774 283620972 73392070 196465913 15885588 306684262 556922243 159267820 448307500 570682768 580413706 138745525 150584459 14061416 757548930 647952289 982022117 970132577 216758157 175049033 311824202 853073402 283861589 699305406 421602081 118404419 368306...

output:

22656

result:

ok 1 number(s): "22656"

Test #74:

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

input:

1
5000
204580885 922234576 533105762 910201182 318781207 967063161 489049671 429825907 975078445 394379736 853532226 106559745 631158067 340620177 289920346 713649138 812824468 537858440 3962939 584883021 698831492 431617439 72296360 494064496 813224590 213575755 791489957 124099651 641871400 347815...

output:

16598

result:

ok 1 number(s): "16598"

Test #75:

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

input:

1
5000
30609642 381673309 104885908 459148763 40618196 973418386 383687249 930686347 654195595 281026568 624354232 234212892 695971501 5101676 327768526 700894075 439074901 149761837 265171231 10595838 956805137 830417776 541342900 790161875 457797863 842321859 475999253 353597786 176663049 39406628...

output:

297269

result:

ok 1 number(s): "297269"

Test #76:

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

input:

1
5000
457268141 26801247 188863244 165551452 186264249 611141688 163147412 744096122 434469057 838681700 436808013 638241503 190657347 324864903 285569033 324912107 975846053 202631427 679785285 961310331 401380203 997723161 597089638 717126504 521903517 344710265 874892397 499220163 154002930 8083...

output:

40242

result:

ok 1 number(s): "40242"

Test #77:

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

input:

1
5000
189005375 657569086 863470892 988959763 556125012 790740351 1844709 264717106 251133146 140028584 721745571 834722261 625073025 877828935 568808772 919529809 82837928 780922754 105414171 457828588 782324800 334876945 73305115 135082011 752585119 154494396 765656571 82520526 433965914 40934912...

output:

39869

result:

ok 1 number(s): "39869"

Test #78:

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

input:

1
5000
1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000...

output:

4999000000000

result:

ok 1 number(s): "4999000000000"