QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#487619#8824. Slay the Spirew4p3rAC ✓2ms3928kbC++201.6kb2024-07-23 02:08:402024-07-23 02:08:41

Judging History

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

  • [2024-07-23 02:08:41]
  • 评测
  • 测评结果:AC
  • 用时:2ms
  • 内存:3928kb
  • [2024-07-23 02:08:40]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int inf=0x3f3f3f3f;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int T;
	cin>>T;
	while(T--)
	{
		int n,m,k,s;
		cin>>n>>m>>k>>s;
		vector<vector<pair<int,int>>> out(m+5);
		vector<int> in(m+5),pa(m+5),sumdeg(m+5),maxdel(m+5,0),minn(m+5,inf);
		function<int(int)> find=[&](int x){return pa[x]?pa[x]=find(pa[x]):x;};
		vector<tuple<int,int,int>> edges;
		long long ans=0;
		for(int i=1;i<=n;i++)
		{
			int u,v,w;
			cin>>u>>w>>v;
			ans+=w;
			edges.emplace_back(u,v,w);
			out[u].emplace_back(w,v);
			in[v]++;
		}
		for(int i=1;i<=k;i++)
		{
			int x;
			cin>>x;
			in[x]++;
		}
		in[s]++;
		for(int i=1;i<=m;i++)
		{
			sort(out[i].begin(),out[i].end(),greater<pair<int,int>>());
			while((int)out[i].size()>in[i])
			{
//				cerr<<"del "<<i<<' '<<out[i].back().second<<' '<<out[i].back().first<<endl;
				ans-=out[i].back().first;
				maxdel[i]=max(maxdel[i],out[i].back().first);
				out[i].pop_back();
			}
		}
		for(int u=1;u<=m;u++)
		{
			for(auto [w,v]:out[u])
			{
				int pu=find(u),pv=find(v);
				if(pu!=pv)
					pa[pv]=pu;
			}
		}
		for(int u=1;u<=m;u++)
		{
			int pu=find(u);
//			cerr<<u<<' '<<out[u].size()<<' '<<in[u]<<endl;
			sumdeg[pu]+=out[u].size();
			sumdeg[pu]-=in[u];
			if(not out[u].empty())
			{
				minn[pu]=min(minn[pu],out[u].back().first-maxdel[u]);
			}
		}
		for(int u=1;u<=m;u++)
		{
//			cerr<<u<<' '<<find(u)<<' '<<sumdeg[find(u)]<<endl;
			if(find(u)==u)
			{
				if(sumdeg[u]==0 and minn[u]!=inf)
					ans-=minn[u];
			}
		}
		cout<<ans<<"\n";
	}
	return 0;
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3616kb

input:

1
6 5 2 1
1 100 2
1 100 4
1 100 5
1 200 5
2 100 3
3 100 1
1 5

output:

600

result:

ok 1 number(s): "600"

Test #2:

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

input:

896
7 3 1 1
2 466121441 2
3 1532237 1
1 980995233 1
3 883122907 3
3 828316196 1
1 346258585 1
3 81103049 1
1
6 5 1 5
2 361294411 1
1 348493623 2
1 844558382 5
4 44546817 4
3 299550642 3
1 150019856 4
4
5 6 1 2
4 835788840 6
2 920119670 4
1 535048546 5
3 291583482 4
6 723170061 2
6
9 10 1 10
6 931952...

output:

2155570014
1250399610
2479078571
1631885933
661315795
4976173188
3776856016
1322348385
2885619544
2902703026
3486930260
3193775292
4606743598
4406041821
2534330773
846418730
941346215
775586917
1414638455
1231834012
726616981
2871942493
4684905026
1540426132
2014162580
1920490214
967023072
104129926...

result:

ok 896 numbers

Test #3:

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

input:

872
6 1 2 1
1 879518762 1
1 984368486 1
1 417093795 1
1 52213339 1
1 59198732 1
1 544467115 1
1 1
10 10 1 8
1 664272138 7
9 141554220 2
3 175762281 4
7 5987355 4
8 496874761 3
9 534579076 9
1 760680640 4
7 579325795 8
2 214165898 2
3 58160053 8
3
3 6 2 4
2 826398556 6
6 308373478 4
2 787200888 6
2 5...

output:

2936860229
1665843008
1134772034
631023058
2811270155
238214896
3044575183
1560464337
2684497650
1692901320
3275318585
2125060442
3100782058
826106838
3034889383
454051215
426208334
4079543979
2355125132
4977568529
1370399582
5381460593
98851256
4027763844
2283539573
3314838242
4483676645
976200158
...

result:

ok 872 numbers

Test #4:

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

input:

919
4 10 1 6
7 778099748 10
2 226189698 2
1 829269222 9
2 169841651 3
5
4 1 3 1
1 533442833 1
1 349376728 1
1 661403099 1
1 453962762 1
1 1 1
3 1 2 1
1 282867923 1
1 22644745 1
1 511623935 1
1 1
8 1 2 1
1 498018215 1
1 531829717 1
1 797957980 1
1 250895023 1
1 204992714 1
1 513574910 1
1 465528176 1...

output:

169841651
1998185422
817136603
3890862944
1654657148
231024582
4697881965
1606961931
1282100222
1869130099
3981185793
1751431120
1179564001
1187083168
205297310
1201994837
3738118328
5236394013
6197558111
3127506724
396219366
2200533321
0
1896463660
995664751
402158876
1885064908
2728868681
14064296...

result:

ok 919 numbers

Test #5:

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

input:

895
5 4 1 1
3 320504920 4
1 926107702 4
1 443699050 4
2 519936686 4
3 310339447 3
3
5 4 4 2
1 861067076 4
4 895910629 1
2 533886752 4
4 231999408 3
4 626641903 3
1 1 1 4
1 7 2 4
4 233972830 3
7 6
6 1 4 1
1 837034210 1
1 736832253 1
1 876711848 1
1 400792710 1
1 87319361 1
1 284753413 1
1 1 1 1
8 10 ...

output:

1556952069
3149505768
233972830
3223443795
2701577168
3308395760
6284275648
4535385808
145622767
2298344576
1231300901
500782587
1430724678
1763937812
5406231679
1817853793
239368435
4295838763
2550115748
2559598524
701318040
942353190
3924675756
220635518
708006662
982839521
2610068167
837797503
29...

result:

ok 895 numbers

Test #6:

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

input:

916
10 9 1 4
5 225916883 5
5 293802092 7
9 60295683 4
1 190670821 5
3 601704714 2
9 573315153 1
7 213946343 4
9 351586439 1
4 348600219 4
2 421642601 1
4
1 8 1 7
7 787526912 6
4
3 2 1 2
2 669525106 1
1 597124440 1
2 579716865 2
1
7 7 1 3
4 429880100 3
1 451146432 3
6 547992780 3
4 138313415 1
7 3029...

output:

1694578959
787526912
1846366411
1350034899
2894709305
2365158660
0
3740841492
967612353
489893066
2823472070
3062920760
2828936378
0
2884036360
1098338266
556719928
1931711979
696161031
0
2729096602
675762248
2006797467
0
1565386455
177315960
0
0
3272472593
3322209053
5459178345
236324367
2887195568...

result:

ok 916 numbers

Test #7:

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

input:

919
1 8 2 4
8 770359776 3
5 5
8 3 2 3
2 93473706 1
1 203313505 2
2 494485918 1
2 996203978 2
2 865156880 2
2 388877911 1
2 402790287 1
1 909007228 1
1 1
1 1 1 1
1 722321155 1
1
3 5 2 2
5 279549659 2
2 993408370 1
1 521860034 2
4 4
7 9 2 4
3 95055233 3
8 182019911 7
5 76066802 3
3 606265638 8
2 40035...

output:

0
3468167509
722321155
1515268404
959407584
1096191870
1834701318
4769137379
757371646
2639560584
2557689159
2246817282
1101772657
2427782088
4210993646
1376094243
995729461
1788303219
3402618912
2938410143
5147377853
390186607
718376652
2745788574
2585359898
3706155162
848783208
3797966035
21141885...

result:

ok 919 numbers

Test #8:

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

input:

906
5 6 1 4
4 82431309 6
2 608292992 4
3 963993589 3
4 584096852 6
2 813679927 1
2
2 10 1 5
3 658159531 7
10 163690981 9
3
3 7 3 5
3 20743502 2
2 335847974 4
5 310522175 4
7 7 7
6 4 2 4
3 956024948 3
2 614889948 1
3 949078134 3
1 877017780 4
1 586430263 4
4 709515215 4
2 2
2 2 2 2
2 515380539 2
2 25...

output:

1480208088
658159531
646370149
3157447891
770745922
3073131056
809591551
1638300789
1435340551
934165359
3377944998
886526952
0
261856277
593019338
1564159399
946536478
1534053319
970226298
4198710573
1204154138
4688736927
550547802
884237688
2478086157
3228953448
509039257
509043432
656950646
29509...

result:

ok 906 numbers

Test #9:

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

input:

891
9 10 4 1
4 422559144 5
4 873193848 8
10 80043191 8
2 417144838 7
8 997886474 2
6 227729227 3
9 89174108 7
7 429558153 5
4 110142020 2
5 5 5 5
5 6 4 3
6 965331288 2
3 635115105 4
1 671067070 4
6 117304718 1
1 25625308 4
2 2 2 2
7 2 4 1
2 834309947 2
2 779699868 1
2 600260777 2
1 642712024 2
1 613...

output:

1844589465
1306182175
4085655090
827743811
196004710
0
2962981728
3599648105
800933099
1921377312
6002038318
1527098545
0
3046507762
2550402912
3072546820
1463830485
721244887
3700944876
2758240117
2583792599
88876473
91174880
1448250113
1276647303
3733726407
3586105383
1713624299
874962648
0
0
0
22...

result:

ok 891 numbers

Test #10:

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

input:

10
210 189 1 37
139 603469304 87
176 33808457 104
185 79785138 97
178 274113252 27
30 411130257 113
170 355737097 82
171 495913444 130
171 325801066 130
57 942835122 64
35 93802427 77
165 444785634 42
150 773332867 21
141 939758252 139
61 737587237 86
114 861718592 183
91 90370602 66
123 400302005 9...

output:

66447671490
26303165234
461837103261
322250931490
108772108212
279444025868
230616316377
23376651588
54240951188
301171520445

result:

ok 10 numbers

Test #11:

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

input:

8
758 139 2 17
66 55434075 47
124 693457340 133
70 22666675 99
61 495281454 18
106 534543785 96
90 595460064 67
21 862626020 57
61 480084383 1
99 132240679 108
53 438956921 67
121 303717227 129
25 508414458 115
42 358621758 138
50 441397416 91
78 267260764 50
76 251677885 66
88 273641100 125
100 323...

output:

326455809149
234387968752
59955543992
314276905582
415612731110
7895805357
275179157030
222728513855

result:

ok 8 numbers

Test #12:

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

input:

8
230 187 1 110
47 209037451 161
133 402504554 51
66 581091477 180
141 988488454 135
96 796387641 167
97 995516487 185
106 844268324 119
24 87219934 150
159 196332014 149
179 287496187 94
34 314942618 40
151 996844785 23
101 852263246 66
117 6022411 88
151 365039700 176
82 879916718 154
178 77657966...

output:

72549508758
227634805879
237308100730
44370497202
251544617765
266991589658
258702514244
296906744139

result:

ok 8 numbers

Test #13:

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

input:

9
608 6 11 2
3 826381543 5
3 586190808 4
5 813182364 1
3 780921431 1
2 850200838 6
1 469629249 3
3 441637899 6
1 887694628 1
3 539503275 4
6 914204901 6
3 170369161 4
1 113232360 1
2 115271098 4
2 345465988 6
5 214158798 1
3 419952806 3
6 540658973 2
3 695395012 2
2 636247636 6
4 913939717 1
1 78328...

output:

309181504397
417743975951
67151472402
227694778668
158654365479
19060987517
119311460053
307261591402
101532739932

result:

ok 9 numbers

Test #14:

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

input:

8
869 352 4 103
124 217962721 78
84 772919135 107
25 46199202 29
246 142039905 171
252 259686320 185
335 828838210 301
244 580427161 236
319 919476114 245
90 966301383 53
299 859851961 317
178 267281349 186
309 985909586 274
71 661424567 137
29 148049864 45
227 171646740 246
279 507333423 143
333 55...

output:

327722559666
308426371776
38260961240
385333427836
198494306027
364653300752
5880676435
408843513039

result:

ok 8 numbers

Test #15:

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

input:

10
274 126 37 34
48 257499639 117
119 262586986 109
109 103011252 59
77 67392300 56
49 60685540 32
62 245226597 106
66 697579675 116
123 552791397 107
61 555649422 5
106 339316249 40
58 571994143 31
1 215286969 76
6 433629351 15
97 772392883 92
13 484218371 27
67 468689879 20
7 921917538 36
94 59807...

output:

97786133213
55501644438
142350240563
299444547748
210971408420
328906597736
38293113229
33257916871
174138552785
82722681820

result:

ok 10 numbers

Test #16:

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

input:

11
324 79 1 14
73 452218721 66
71 778493526 21
2 598194623 20
34 130379412 40
23 291060532 25
78 829282107 25
17 485989828 76
50 184031875 79
68 636091190 11
2 770354272 38
36 72243534 19
33 737803477 67
22 734928713 41
19 693682072 33
15 620710042 54
63 536585960 25
44 669572835 2
39 114884523 16
4...

output:

132202020757
267853271883
0
271821864720
406662699620
237348317545
101537691260
107118864855
1831945132
190114028207
95736716965

result:

ok 11 numbers

Test #17:

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

input:

7
977 325 2 33
48 694533111 36
68 172847569 17
94 651075221 137
68 711946907 218
319 358402118 35
54 498093388 223
269 919541435 233
325 286907879 254
146 975216329 117
264 465609341 234
7 599145683 194
317 954979388 300
270 195927414 325
222 684190395 124
138 740308083 152
65 65305989 59
292 103795...

output:

379468075568
37210647848
371529118150
431860612088
195442456916
98281713126
273062050400

result:

ok 7 numbers

Test #18:

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

input:

8
345 269 5 192
105 326450944 227
250 95281219 1
116 565339004 86
119 556641821 15
189 349871836 23
255 319597858 11
49 563517479 49
116 727576073 211
25 674924868 107
230 37619542 6
185 261172075 168
190 539133548 209
5 882864588 145
198 304933078 248
140 868117630 110
57 732034003 245
207 60854314...

output:

101482995478
252471697334
254237085748
298530322820
162515044967
12061977391
179964458390
336908437413

result:

ok 8 numbers

Test #19:

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

input:

9
530 487 9 151
458 929223616 152
269 570438335 438
441 381335732 317
108 889695226 307
376 734090721 230
377 893911108 163
390 641802549 180
277 221063291 364
148 994659333 285
23 565467062 301
141 712657925 239
154 584025190 231
420 709149061 313
391 143511213 61
53 211500275 405
377 956948991 273...

output:

141647131336
128786029889
87268919264
312954621279
161837481682
3728453493
138921374732
265593697134
481311360398

result:

ok 9 numbers

Test #20:

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

input:

5
984 242 23 191
68 373870387 73
122 272257984 29
106 510980445 85
190 630343511 192
55 170728504 156
118 885222537 134
151 560450168 6
89 958394708 215
85 152919581 186
170 299676316 163
169 854799548 57
47 299670045 242
73 315008019 19
56 213510806 65
106 528198349 113
103 837250100 84
187 4469605...

output:

403531411892
399184661318
147648923675
405371565416
427619542476

result:

ok 5 number(s): "403531411892 399184661318 147648923675 405371565416 427619542476"

Test #21:

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

input:

12
685 4 55 1
4 506752343 4
3 391473671 1
1 779934695 1
1 885582736 1
3 176172529 2
3 7947456 4
2 796846175 1
1 26829204 3
2 747819676 4
3 514197636 2
1 81931472 1
3 919477463 1
3 21214556 4
2 704062022 4
1 58201493 3
4 632736725 4
3 356434372 3
2 574858734 4
2 101199454 3
1 957401535 1
2 198412416 ...

output:

340654073682
176667713334
73820534560
16772408503
38155806858
34863642465
30715911108
225633654778
80323239239
114060989172
464549581584
14017519879

result:

ok 12 numbers

Test #22:

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

input:

21
250 368 1 142
30 743468285 192
368 848005730 117
328 210772658 161
264 362186624 79
236 965870673 345
173 618163474 13
307 491105797 207
258 295208767 110
356 268259614 251
251 645445687 259
116 677584556 228
145 212570096 198
110 561413978 184
56 749997343 42
174 280704648 59
272 615597946 339
1...

output:

59134011973
87789100706
102826759842
71387227919
56963326181
2618855906
61915753041
76270424549
60221290879
83952144758
58568500677
0
44846487035
28491214879
39088046690
47890786871
35623039246
95022381778
484139150
7065424750
52478833615

result:

ok 21 numbers

Test #23:

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

input:

18
298 114 2 81
33 547100454 72
111 114127114 48
9 263988090 59
109 411532834 82
32 320732433 58
86 579639115 5
55 923852236 40
1 904285003 6
57 227292442 98
61 936437738 86
54 972715884 106
112 358605819 48
33 7704539 74
5 407855529 38
23 916115991 55
54 35759877 22
35 668999315 43
36 209698509 32
...

output:

115397085731
44288840683
69410295866
38500623858
11176610187
3346725029
54951754235
117591490078
10335440291
78090545355
38331630700
0
23534027193
21472414127
67255364851
5541738229
3287488868
10187767985

result:

ok 18 numbers

Test #24:

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

input:

20
293 331 4 323
313 437078584 284
142 462721567 38
299 132577330 21
142 799280494 124
233 368272399 56
108 780185663 264
319 996488775 18
55 627260470 71
104 643859778 322
325 722516807 228
244 209239853 313
242 353152294 80
191 928006655 121
86 5869298 289
35 37852102 103
208 276827933 324
250 244...

output:

68971438954
9718599100
86363531422
33347944559
57473801720
14616608461
67609373152
34301331219
9332190789
76622885026
3161425467
26017549660
12691621974
54114876752
18632190036
57795215352
33732772407
44683873535
1561664590
47768228988

result:

ok 20 numbers

Test #25:

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

input:

21
182 49 19 31
44 571970255 27
43 407970914 17
21 278746767 17
45 11645541 28
24 24909229 46
44 580698950 49
11 686474130 10
48 41904773 16
3 531337264 11
42 46327275 19
6 627154267 10
8 963548173 48
2 70643045 12
45 670801924 23
14 659497725 42
32 647962219 18
46 350198856 35
43 279344537 2
19 613...

output:

75599644913
133899608897
2396166769
55216142339
41023646586
15412677772
19923917916
22160407644
7010598118
54248276243
60086990390
47586089258
1428257268
17817278956
22074333995
698391357
46343012800
93694393841
1651448978
75801368926
53881388610

result:

ok 21 numbers

Test #26:

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

input:

16
236 304 18 252
80 737658795 292
67 957569805 195
212 640070975 229
32 579059255 5
132 981398689 81
161 309781724 119
255 939184370 142
190 571921391 251
289 646797668 185
57 323407348 278
268 328810565 178
169 9339304 155
201 381263948 102
90 218120940 173
207 707332644 125
259 714001400 277
210 ...

output:

57650837199
23314218896
19340213400
0
16342537109
37570952042
5113257724
107393805655
3476816593
42340270724
25183629725
44155933159
2402702992
45463439617
68928057146
105385027

result:

ok 16 numbers

Test #27:

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

input:

20
49 406 8 405
378 577861861 113
111 302289469 230
74 519432755 348
170 127160443 322
233 32471532 97
181 488817533 322
171 78957163 239
142 156741158 96
346 661415899 254
323 987062447 370
100 93972240 271
115 2818208 71
284 150936488 127
55 152014354 176
83 960017250 61
388 213238820 348
306 6414...

output:

3779153265
43279782621
7986918258
8606276996
9483495273
89150972082
59676022845
41246751475
60199848739
34672013382
8069384146
51215970187
44480829958
10787509274
127631880116
112966108683
24639367793
131902317678
15553437656
101610689105

result:

ok 20 numbers

Test #28:

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

input:

22
273 54 1 30
39 496307851 18
6 767922647 20
44 899182808 9
31 201242816 46
17 49414725 2
30 965956886 38
4 164122294 50
41 854657914 14
46 799150750 15
34 625471147 46
31 47634857 31
26 687459022 9
37 158881706 24
28 680028415 37
43 591067079 18
32 370478360 39
31 815560675 39
54 869718465 35
51 5...

output:

124853058460
67255234914
1834311644
74231414770
8902114688
88814456773
51071293186
19359016199
988586925
70256861881
3442508898
44048126728
39179890826
57689861146
5178297895
111323476026
27780287576
0
25683022758
77094295883
13305216530
32720033482

result:

ok 22 numbers

Test #29:

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

input:

19
13 300 2 107
166 801640069 141
27 439813623 114
223 5410797 61
265 823810363 245
180 576980591 152
207 165881124 274
208 139657147 284
206 68609101 165
190 266064636 195
9 136596707 192
146 650036823 217
14 161409601 146
16 355742120 19
243 243
206 2 2 2
2 301519574 2
1 125905567 2
1 645606839 1
...

output:

650036823
108844574664
18001637391
203073611
64526310856
21655245940
46857012429
45403384823
1741788658
48540027523
15168097484
38279473816
20369678340
1688650871
73402747933
55197764530
31454824014
64487270565
15349940876

result:

ok 19 numbers

Test #30:

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

input:

20
8 17 2 16
10 907871414 9
15 761632234 17
4 75846748 3
9 796621971 16
12 905268584 1
2 160781999 7
10 132772730 12
14 807144264 1
10 10
267 215 10 143
101 849889989 25
132 581229521 50
85 205619662 34
190 278916161 82
114 641319409 191
192 225768924 98
149 920870332 134
212 29635874 205
119 946844...

output:

2742534699
72176156046
27879858143
5163579852
36036559073
364439395
141342271607
90975788995
25100320838
98337878769
60416812459
5020402724
35810908528
0
7728923401
5425106333
4750224826
2746539067
33779329586
36879564023

result:

ok 20 numbers

Test #31:

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

input:

22
197 439 13 184
106 351240331 174
93 276088243 411
298 548641725 339
380 555248668 140
338 422015609 280
256 866357924 273
29 205785596 235
17 822768269 422
139 494999633 211
384 575040857 416
331 648869829 141
165 341912281 214
433 79686286 253
355 58821491 202
330 63622839 106
292 769681587 149
...

output:

39722642771
4090141088
68289102335
0
20435098339
60411099816
134737078002
89539627321
73286824760
69488309266
28551825950
24751032215
44954318414
58355222600
17093640155
25177040137
40324938450
1162890461
57352084965
62519758202
79833952192
38110274009

result:

ok 22 numbers

Test #32:

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

input:

16
251 285 36 258
194 216251649 264
243 412725864 164
125 881267728 104
238 121348019 222
144 12000030 282
81 903659687 162
250 442262299 146
181 424038676 187
115 888826556 74
32 998970980 115
14 170127224 279
72 338966201 135
87 545144772 27
153 659295049 208
101 156005003 153
112 661887990 36
156...

output:

65235879666
67270750590
0
0
0
20786083849
69086583870
14470072475
63667434541
75978381006
1364970944
14692433923
47364664302
47198455937
63496633705
6090341288

result:

ok 16 numbers

Test #33:

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

input:

20
64 388 27 4
176 753687395 27
305 601200136 323
65 317477981 254
304 124501919 179
48 274500421 29
382 869413869 319
216 215241118 240
237 191400760 223
361 530329426 234
252 133269259 253
317 247677302 237
325 950704799 247
116 691033952 171
187 278059398 161
102 368901612 115
262 907529882 109
2...

output:

6119205103
84000331649
15070574481
5469997016
8324726454
37556915383
3739687015
103280703708
0
2828710283
20232880775
0
33998572297
42363792174
127508671620
29066243995
6379898452
31970394155
52743349641
976990355

result:

ok 20 numbers

Test #34:

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

input:

500
10 10 1 9
10 918272408 3
3 944627956 1
6 377179334 7
2 333924394 4
6 903719198 5
5 101097248 4
7 337436105 4
3 281974168 4
9 364007268 3
7 738247986 8
4
10 10 1 8
8 47199758 1
10 279645030 9
5 291259909 10
2 962186488 10
4 960053937 4
8 156190596 10
5 555771686 2
7 925159766 10
2 232613933 9
10 ...

output:

2429954626
2347258556
2853243396
3207481873
3078809335
2428384479
2024373065
2289554835
2746752776
1875883286
4011296552
2239599505
3546303134
3013085703
2353422793
766449371
2821127002
4031217591
2021933903
3769576809
3606320761
2299238364
3145815377
2687222620
2405578734
4413379843
1814842212
4515...

result:

ok 500 numbers

Test #35:

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

input:

500
10 10 2 8
5 745064606 9
6 916064826 1
3 628127507 1
5 578090424 7
3 755209913 2
6 888495802 5
5 688244990 10
7 712624267 1
7 641067832 1
3 356725057 8
6 5
10 10 2 5
1 61349235 1
7 522516273 7
5 665149246 2
7 301408452 2
5 586475127 8
1 208224108 6
8 745068594 5
1 22601233 4
6 202377588 6
4 51245...

output:

3061998689
3221157745
1970385964
4559656778
3096990971
2264713156
3834596122
3886148618
2497120175
4895504510
4147972354
2098474899
2902909979
4392628651
4356108427
3875603129
3238303079
1118202175
3365057033
4410576409
4305066652
4500978323
2219884177
1781413130
2031354765
4228690443
2083035899
426...

result:

ok 500 numbers

Test #36:

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

input:

500
10 10 3 6
9 717080995 4
10 447310209 2
1 584108385 9
6 677032262 3
4 456957523 4
7 970861651 10
7 744086579 2
10 438241663 10
6 918128396 2
9 120426319 5
5 8 6
10 10 3 3
6 741173554 2
7 825307730 4
1 803884205 3
1 783307305 10
2 628444526 9
5 603602025 8
7 530542038 8
4 198412634 10
10 585986011...

output:

3654751048
3561502955
4484596343
2813182267
4072823044
4380115238
4060268841
4529879876
3908461603
3354612510
2780395007
2618381371
1959504979
3033026052
4395677350
3400851309
4266606072
4004022715
1630916161
1795861013
3280899742
3224566006
4239242014
2877613882
3268536214
3856046462
1562171567
438...

result:

ok 500 numbers

Test #37:

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

input:

500
10 10 4 1
3 133807785 2
3 418747079 4
7 835056559 8
8 921198292 6
4 308448238 2
10 613036013 2
4 359736680 8
4 18634866 9
9 900221665 10
8 738903389 10
5 6 3 6
10 10 4 4
3 39967056 2
2 388940096 10
3 73549471 8
4 475914259 6
3 371246605 1
9 378476186 1
3 841233302 3
9 630335573 5
3 655931153 10
...

output:

3951843118
2733265415
3697220630
2130919699
2783465366
3846781126
3836700401
2364016112
4281617104
3044865224
2081835502
3198679059
2314504701
4557472804
2594350515
2779971728
2936692253
4041430780
3490389794
2591859773
2310729755
3243650510
3686527316
4087825117
3757954107
3753938899
2274085107
221...

result:

ok 500 numbers

Test #38:

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

input:

500
10 10 1 4
1 403754943 4
2 378973190 3
1 133283750 5
4 23347893 8
4 330579404 4
8 904252448 6
6 216453042 10
2 207278364 6
7 327084001 2
4 413498700 1
1
10 10 1 3
10 881455994 8
1 947323157 3
2 385885150 2
1 732141504 3
4 270132863 10
9 811061037 6
5 646241467 2
10 578664747 5
7 938670136 10
2 37...

output:

2804143370
3135805784
2501351648
1582305670
5356759759
2755540309
3432081444
2509617173
1976700299
2610132283
2812387156
2192205451
3441185852
2077696156
3792574660
2416061588
3113839120
3308199880
2921189465
2348380809
2129779092
3717338719
2251072154
1973780155
2991641267
1738445449
2449921973
242...

result:

ok 500 numbers

Test #39:

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

input:

500
10 10 2 10
8 525514436 7
5 55442764 4
9 89264628 3
7 827322435 1
6 887102823 5
1 546426810 7
4 567261927 6
6 787671567 4
1 604144565 6
1 177199963 2
7 7
10 10 2 2
7 940139778 3
2 398915001 1
10 378572871 2
5 760726776 3
8 883784096 9
9 881240069 1
1 203895266 9
7 650517995 9
8 444449691 1
9 5222...

output:

3728946081
2006266702
3635969267
3722348918
2119747824
4624227008
4935579464
2162809663
3059133215
3339019169
3378674578
2539142879
2937995935
2155809124
1830653964
2867814993
2697927189
1914275378
4102279845
3453042119
2383598404
4076372797
2742784648
515959183
4047849497
3774002282
2382841772
1058...

result:

ok 500 numbers

Test #40:

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

input:

500
10 10 3 9
10 352306634 7
9 586688147 4
5 45245505 10
8 71488465 5
7 738593538 3
5 333825363 2
6 623103516 4
6 513288963 9
10 586237833 1
7 795677033 3
9 9 9
10 10 3 9
9 853599369 3
6 700763740 8
2 931069104 3
5 229503535 6
10 57243840 9
9 511227613 8
2 911292168 5
1 867595436 2
3 390420733 8
3 3...

output:

2302428376
4049867806
2423087393
5028644898
2911724279
3230458555
2073568812
2145736870
4671171161
2968034544
2321881266
3687619801
2992224514
3206729386
2328128834
5570888777
3164995947
1994781031
3281062582
4395634757
3860987492
3244534094
3040705837
1176094920
3246347644
2825411871
3862971045
437...

result:

ok 500 numbers

Test #41:

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

input:

500
10 10 4 2
6 619290320 7
2 263157721 9
3 1226383 8
10 315654495 9
1 440341148 5
10 416191213 4
3 533720912 10
3 238906358 10
7 863298398 5
7 559378295 4
9 9 9 9
10 10 4 2
6 472091664 9
3 2612480 6
9 483565337 7
2 403312999 10
8 80960481 10
2 581406645 7
8 468945967 1
4 644481388 7
8 896200288 6
1...

output:

1858301827
2875272727
3741902385
3179937590
3958015564
2485980179
2591870591
4264027875
3532770308
1432932019
2876234666
2719805445
4434998593
2944903223
3710552005
2396931152
4040253703
2476783460
2526666453
3110927264
2233256561
2926156585
2089889230
1655203759
3699433093
2461808370
3118918080
256...

result:

ok 500 numbers

Test #42:

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

input:

5
1000 500 1 55
338 594187915 206
227 449949050 380
392 224042646 374
189 58475735 68
389 504407176 64
200 169304034 142
46 126598568 457
46 886950919 460
208 365674336 55
371 124788171 276
458 148180341 156
289 578873637 30
265 666880391 112
464 620588825 174
37 532789705 435
41 404116123 111
140 7...

output:

360253458933
351220749350
337240536163
348593059004
343101774104

result:

ok 5 number(s): "360253458933 351220749350 337240536163 348593059004 343101774104"

Test #43:

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

input:

5
1000 500 2 203
87 109295425 484
110 25291963 441
113 247756958 438
59 822953301 190
476 210176580 496
312 293534109 168
284 32781965 68
265 901518078 445
205 981988444 139
411 281316638 498
276 127303434 208
314 920233575 234
48 75003542 425
268 541279443 377
76 652434440 9
406 612919543 100
239 4...

output:

353097000893
349085952725
354467318176
350748736807
347481123440

result:

ok 5 number(s): "353097000893 349085952725 354467318176 350748736807 347481123440"

Test #44:

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

input:

5
1000 500 10 222
442 161959253 392
395 803114403 165
44 838910090 244
318 976556677 366
394 64447986 171
343 997183102 51
495 376245860 68
327 898520718 78
497 792110275 393
172 557926238 332
195 584695882 431
193 279292206 5
64 68767000 166
215 992696321 66
367 435832063 284
139 811593735 201
34 9...

output:

339804038008
327240731257
354072214813
358698185496
345880017753

result:

ok 5 number(s): "339804038008 327240731257 354072214813 358698185496 345880017753"

Test #45:

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

input:

5
1000 500 20 408
238 795217969 157
430 598440908 488
217 967845737 154
45 412577691 155
5 193357680 244
389 152025538 79
42 55715579 435
123 293119916 465
488 646794625 264
1 743095675 191
22 88856950 366
242 970654821 167
487 175549896 224
13 296991308 319
64 464132247 240
308 807721633 339
106 89...

output:

358540057895
348131705870
360136228376
342451746567
369500635111

result:

ok 5 number(s): "358540057895 348131705870 360136228376 342451746567 369500635111"

Test #46:

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

input:

5
1000 500 50 78
225 135185605 54
13 984420426 271
339 359171588 202
112 985481947 432
418 139895272 159
146 612033932 277
285 234830016 125
105 771884805 343
462 625431997 389
167 999117779 360
90 6886653 194
387 459326983 37
157 200931286 400
313 945035053 190
54 279672672 118
418 620755056 43
320...

output:

348017386957
357340567874
347640658313
340169733601
368221784082

result:

ok 5 number(s): "348017386957 357340567874 347640658313 340169733601 368221784082"

Test #47:

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

input:

5
1000 500 100 399
431 758008641 444
441 739376028 49
298 342355578 281
285 278242406 70
98 42504842 419
224 823334369 7
353 210152904 122
218 615209737 126
148 158953383 406
194 479376158 380
235 37669841 192
368 485572571 1
100 188838018 360
466 233403125 235
111 483336231 89
457 531324632 20
480 ...

output:

363854968834
368638429674
370075560583
362029208549
366956611547

result:

ok 5 number(s): "363854968834 368638429674 370075560583 362029208549 366956611547"

Test #48:

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

input:

5
1000 500 1 52
228 158053180 206
443 170165874 108
385 956276363 354
335 616080717 294
402 902216544 163
393 153551562 497
482 694751935 208
161 290692011 257
202 689755707 342
29 844037326 105
291 643312288 187
458 912242299 283
379 122036449 35
155 566818282 176
215 75078468 224
213 874908953 484...

output:

329483274672
343465936353
343461554687
348525160805
336200754819

result:

ok 5 number(s): "329483274672 343465936353 343461554687 348525160805 336200754819"

Test #49:

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

input:

5
1000 500 2 305
477 673160689 484
326 895251890 465
107 979990676 407
205 940366795 316
1 313018653 299
302 277781636 227
423 451192228 218
380 600226465 334
95 11102519 130
69 705598497 315
405 767659573 431
383 253602237 475
470 235192304 156
164 487508900 379
51 339947395 14
78 83712372 65
137 7...

output:

347448598074
350540880012
351774187932
358144734956
344469561055

result:

ok 5 number(s): "347448598074 350540880012 351774187932 358144734956 344469561055"

Test #50:

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

input:

5
1000 500 10 27
128 20791813 188
111 673074330 393
50 571143808 417
465 239194362 388
408 462257355 78
36 836206438 406
327 944399228 126
442 862070321 466
195 116191646 385
330 277175393 353
133 374795124 450
466 757885060 258
486 818890355 397
303 643958482 67
354 683153530 73
15 987419269 474
14...

output:

356755125004
347671811960
358370783415
344011746326
343773442160

result:

ok 5 number(s): "356755125004 347671811960 358370783415 344011746326 343773442160"

Test #51:

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

input:

5
1000 500 20 213
128 359083233 452
442 468400836 320
223 700079454 134
283 824958480 178
315 591167049 151
83 136273065 433
477 769093138 481
34 551636815 58
186 970875996 256
351 167377534 212
151 729213089 397
411 304023483 112
205 630705954 456
100 243220765 320
346 151645202 233
184 838322975 3...

output:

339835378623
335691947589
360425304934
341462720227
331989498280

result:

ok 5 number(s): "339835378623 335691947589 360425304934 341462720227 331989498280"

Test #52:

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

input:

5
1000 500 50 75
411 994018165 53
229 999604545 498
344 236629498 479
66 102895441 454
136 832671936 462
339 301314163 324
116 802983383 171
220 325369001 436
351 949513368 381
18 718366934 381
423 502018600 417
352 792695645 291
80 951054640 132
197 891264510 487
133 967185627 418
295 386515181 7
2...

output:

359239884216
325238522908
357264136417
347649156487
340326552895

result:

ok 5 number(s): "359239884216 325238522908 357264136417 347649156487 340326552895"

Test #53:

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

input:

5
1000 500 100 396
117 616841201 239
453 754560148 380
304 74589295 158
432 395655900 93
124 735281507 326
418 662357704 362
185 218497760 273
129 18950828 218
346 483034754 101
353 198625313 197
172 532801788 210
129 818941233 446
22 349026781 91
65 179632583 33
98 170849186 286
129 2117461 189
379...

output:

340051533845
350251006324
355640845637
344914465197
335693981795

result:

ok 5 number(s): "340051533845 350251006324 355640845637 344914465197 335693981795"

Test #54:

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

input:

10
300 500 1 247
338 662272921 480
323 796473779 411
426 124190236 429
316 554126062 370
489 736892102 227
116 522558019 136
91 676678810 340
274 47038591 215
122 453906644 440
53 138502361 209
221 309482455 325
154 863295611 354
433 888591449 132
28 519211089 17
400 816195277 406
332 472826129 132
...

output:

52736703280
57546750706
60077501425
52008474830
66371239814
62650058802
54781545526
64491888354
64366029542
52932814046

result:

ok 10 numbers

Test #55:

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

input:

10
300 500 2 48
246 226694484 210
60 112722584 113
40 578948883 222
5 580505578 158
233 598453273 141
434 501681112 188
207 313006044 440
161 455161742 336
426 224854157 144
389 258147096 283
382 223318579 6
445 386135968 180
423 361318153 147
403 593110249 151
483 377860889 59
375 411240459 292
67 ...

output:

66334004698
57806375189
62403385520
58513647649
60912776009
56792791402
55391600603
61467897124
59703148728
57604638989

result:

ok 10 numbers

Test #56:

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

input:

10
300 500 10 500
434 985432900 381
107 756216354 199
77 258135052 302
498 859476057 453
58 734304717 364
301 541124676 78
295 195873810 96
271 166484845 124
377 220261755 417
149 28981732 326
32 131567857 125
434 437324702 82
271 468130345 191
135 812751629 85
405 822281053 454
262 727332608 101
33...

output:

52669190895
63430504279
70218252923
61964827985
61586378851
55280791159
64183815298
56998678251
61764680687
66248727766

result:

ok 10 numbers

Test #57:

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

input:

10
300 500 20 490
289 845308040 409
357 580910265 55
373 652734250 393
489 273968919 132
79 359665642 19
228 45285745 217
241 742012233 450
491 568235036 387
174 819524038 78
142 202506108 282
497 687504267 158
6 251606093 249
55 743523929 324
208 292217901 61
207 170686898 139
108 531864685 245
461...

output:

57395480201
59955632869
67658642951
54689752632
63212421996
58263852024
60845595339
62843280316
61384023922
58869295709

result:

ok 10 numbers

Test #58:

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

input:

10
300 500 50 82
33 305316434 312
101 614800509 53
355 866657923 67
462 547573587 245
449 470463553 392
296 963315448 341
477 820618987 128
365 298649130 358
475 172600486 246
429 167789637 160
299 940729178 362
4 284384858 46
396 274737385 396
245 880359822 106
109 805839025 384
148 975586997 356
4...

output:

66735449304
68992601368
63644443883
62362396515
69132989238
61338183045
70096655926
64045447925
63296125632
68345439386

result:

ok 10 numbers

Test #59:

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

input:

10
300 500 100 480
458 800152837 394
399 484920476 141
186 443672141 431
167 396990002 336
145 13228612 311
214 800586746 369
370 537552388 470
11 420206880 60
436 574183746 246
89 431619207 449
159 977383838 352
106 422116795 459
319 4728874 209
328 140631577 385
323 191512889 482
13 995772989 43
8...

output:

69445939318
63045319316
73899382121
74598056930
67008765100
72493461663
75372221177
87489041274
71845909335
76153970422

result:

ok 10 numbers

Test #60:

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

input:

10
300 500 1 116
31 646520449 26
450 69659850 253
41 822898624 225
106 878207433 361
148 161173961 56
450 17689966 166
351 10047472 94
196 502194649 446
17 105168805 134
40 826015316 202
97 780275284 290
256 457173574 222
324 831860866 416
112 371328373 397
480 353191461 104
473 708198273 479
321 87...

output:

55814969636
61884452336
57695436001
61864042231
57311710315
58144901588
62930500746
62576680042
57129447166
53208654576

result:

ok 10 numbers

Test #61:

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

input:

10
300 500 2 416
440 65717820 460
391 826100143 364
451 132433078 314
499 904586949 445
392 317702428 470
63 437004547 410
184 646374706 490
287 615350504 67
321 466050910 145
375 945660051 480
462 399144112 279
355 980013931 252
110 159363378 431
191 590451725 31
63 765113969 257
16 646612603 127
4...

output:

60024143439
64754369696
54823874525
52259235414
60904129850
54190557539
52542766271
59045719280
59281953472
64168090402

result:

ok 10 numbers

Test #62:

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

input:

10
300 500 10 165
231 529488940 428
438 469593913 42
192 661876143 98
196 743365940 444
112 453553872 489
443 331223919 97
56 824209769 41
490 916608199 355
272 461458508 419
124 276303199 319
204 162169199 294
332 736235368 154
162 266175571 475
219 810093105 169
485 359277237 152
403 962704751 448...

output:

58611431074
54872694100
51360626619
53802477223
58995940934
52762127658
62111566790
62274505183
59425265448
57605849698

result:

ok 10 numbers

Test #63:

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

input:

10
300 500 20 63
278 829555567 264
485 999320528 113
284 351442637 189
187 598050290 19
441 783947501 348
165 685641884 43
309 370348191 203
413 728423799 414
274 765753495 376
425 744794872 275
77 863329801 123
404 550516760 117
446 541569154 405
495 289559377 146
479 2650378 337
249 62204125 284
3...

output:

61982220762
64620723746
59754449284
57883671402
48381139922
49852383604
59102030778
62276300993
61912442671
63297969286

result:

ok 10 numbers

Test #64:

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

input:

10
300 500 50 450
430 289563961 359
432 33210772 303
266 830207527 363
160 576687662 236
108 894745412 221
437 163480099 268
454 299211841 370
288 48772485 90
370 413797239 247
108 265368000 357
175 411522007 327
118 878262821 413
275 777815314 181
33 437509810 179
381 488059401 286
290 210959140 40...

output:

59627084212
61921227336
56722301461
59239395356
60180839145
63829931184
62492709163
57598402829
61931396979
57912715529

result:

ok 10 numbers

Test #65:

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

input:

10
300 500 100 145
447 344208876 441
230 53073843 391
97 847413232 23
457 721071373 328
496 437510471 332
151 440942885 388
143 16145242 416
125 170330234 87
23 225445907 247
64 119132162 442
35 7985180 225
312 721027462 30
210 358063700 481
116 137973054 162
96 873733266 475
154 376369325 186
459 4...

output:

54894179347
53104458774
64068210171
55082000931
59135848624
62386506122
64664699219
61268145436
63067346000
59922127743

result:

ok 10 numbers

Test #66:

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

input:

10
300 500 500 161
70 246557827 37
369 292256701 178
245 959854499 249
391 500302941 370
72 371138734 83
446 765522486 349
23 567446197 69
313 954202667 391
157 51315952 396
187 985441815 463
71 909859255 15
449 536649711 125
78 743996097 128
41 707663897 190
104 596642972 123
275 675748620 407
202 ...

output:

55488271732
62669764858
64370808681
49086298406
51545384886
55444439505
62613927241
59683649965
64619348677
62677314977

result:

ok 10 numbers

Test #67:

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

input:

5
1000 500 500 82
36 944530222 289
289 901904328 429
336 793531881 319
324 332702760 290
57 815211523 53
29 564706654 353
131 17489129 264
468 281135199 136
372 557233618 452
121 132253576 448
275 152348685 171
317 515466380 396
402 427866509 191
390 710535331 386
221 627093431 307
369 609024241 480...

output:

353160966516
349549737727
361062393712
330529914069
347451877769

result:

ok 5 number(s): "353160966516 349549737727 361062393712 330529914069 347451877769"

Extra Test:

score: 0
Extra Test Passed