QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#139452#2675. Sky walkingHe_Ren100 ✓1926ms84644kbC++173.6kb2023-08-13 16:18:272023-08-13 16:18:29

Judging History

This is the latest submission verdict.

  • [2023-08-13 16:18:29]
  • Judged
  • Verdict: 100
  • Time: 1926ms
  • Memory: 84644kb
  • [2023-08-13 16:18:27]
  • Submitted

answer

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

ll min_distance(vector<int> a, vector<int> h, vector<int> pl, vector<int> pr, vector<int> py, int beg, int enn)
{
	int n = (int)a.size(), m = (int)pl.size();
	
	vector< vector<int> > eff(n);
	for(int i=0; i<m; ++i)
	{
		eff[pl[i]].emplace_back(py[i]);
		eff[pr[i]].emplace_back(-py[i]);
	}
	
	vector< vector<int> > keys(n);
	for(int i=0; i<n; ++i)
	{
		keys[i].emplace_back(0);
		keys[i].emplace_back(h[i]);
	}
	for(int i=0; i<m; ++i)
	{
		keys[pl[i]].emplace_back(py[i]);
		keys[pr[i]].emplace_back(py[i]);
	}
	
	static int sta[MAXN];
	int tp = 0;
	auto getsta = [&] (int y)
	{
		int l = 0, r = tp;
		while(l<r)
		{
			int mid = (l+r+1)>>1;
			if(h[sta[mid]] >= y) l = mid;
			else r = mid-1;
		}
		return l? sta[l]: -1;
	};
	
	for(int i=0; i<n; ++i)
	{
		while(tp && h[sta[tp]] <= h[i]) --tp;
		sta[++tp] = i;
		
		if(i == beg || i == enn)
		{
			for(int j=0; j<m; ++j)
			{
				int v = getsta(py[j]);
				if(v != -1) keys[v].emplace_back(py[j]);
			}
		}
	}
	
	tp = 0;
	for(int i=n-1; i>=0; --i)
	{
		while(tp && h[sta[tp]] <= h[i]) --tp;
		sta[++tp] = i;
		
		if(i == beg || i == enn)
		{
			for(int j=0; j<m; ++j)
			{
				int v = getsta(py[j]);
				if(v != -1) keys[v].emplace_back(py[j]);
			}
		}
	}
	
	multiset<int> q;
	for(int i=0; i<n; ++i)
	{
		for(int t: eff[i]) if(t < 0)
			q.erase(q.find(-t));
		
		vector<int> nkeys;
		auto push = [&] (int x)
		{
			if(x <= h[i]) nkeys.emplace_back(x);
		};
		auto pushall = [&] (int x)
		{
			push(x);
			auto it = q.upper_bound(x);
			if(it != q.end()) push(*it);
			if(it != q.begin()) push(*prev(it));
		};
		
		for(int t: keys[i])
			pushall(t);
		if(i > 0) pushall(h[i-1] + 1);
		if(i+1 < n) pushall(h[i+1] + 1);
		
		keys[i].swap(nkeys);
		
		for(int t: eff[i]) if(t > 0)
			q.emplace(t);
	}
	
	vector< vector<int> > lef(n), rig(n);
	vector< vector<ll> > f(n);
	
	for(int i=0; i<n; ++i)
	{
		auto &vec = keys[i];
		sort(vec.begin(), vec.end());
		vec.erase(unique(vec.begin(), vec.end()), vec.end());
		
		lef[i].resize(vec.size(), -1);
		rig[i].resize(vec.size(), -1);
		f[i].resize(vec.size(), linf);
	}
	
	q.clear();
	map<int,int> bak;
	for(int i=0; i<n; ++i)
	{
		for(int j=0; j<(int)keys[i].size(); ++j)
			if(q.count(keys[i][j]))
				lef[i][j] = bak[keys[i][j]];
		
		for(int t: eff[i])
		{
			if(t > 0) q.emplace(t);
			else q.erase(q.find(-t));
		}
		
		for(auto t: keys[i])
			bak[t] = i;
		
		for(int j=0; j<(int)keys[i].size(); ++j)
			rig[i][j] = q.count(keys[i][j])? -2: -1;
	}
	
	bak.clear();
	for(int i=n-1; i>=0; --i)
	{
		for(int j=0; j<(int)keys[i].size(); ++j)
			if(rig[i][j] == -2)
				rig[i][j] = bak[keys[i][j]];
		
		for(auto t: keys[i])
			bak[t] = i;
	}
	
	priority_queue< tuple<ll,int,int> > qq;
	auto upd = [&] (int i,int j,ll k)
	{
		if(k >= f[i][j]) return;
		f[i][j] = k;
		qq.emplace(-k, i, j);
	};
	upd(beg, 0, 0);
	while(qq.size())
	{
		ll cur; int i,j;
		tie(cur,i,j) = qq.top(); qq.pop();
		cur *= -1;
		if(cur != f[i][j]) continue;
		
		int y = keys[i][j];
		
		if(j > 0)
			upd(i, j-1, cur + y - keys[i][j-1]);
		if(j+1 < (int)keys[i].size())
			upd(i, j+1, cur + keys[i][j+1] - y);
		
		auto trans = [&] (int v)
		{
			if(v == -1) return;
			auto it = lower_bound(keys[v].begin(), keys[v].end(), y);
			upd(v, it - keys[v].begin(), cur + abs(a[i] - a[v]));
		};
		trans(lef[i][j]);
		trans(rig[i][j]);
	}
	
	return f[enn][0] == linf? -1: f[enn][0];
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 10
Accepted

Test #1:

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

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
20 32
153019885 1
243344664 6
261869171 6
265268248 8
310218263 6
361883678 5
366594908 7
446296926 9
464628496 6
468699538 10
472673652 9
501464856 4
519506274 5
609178860 7
641637373 2
661461264 8
836699595 8
895624610 2
929677373 1
936454105 10
12 13 1
8 10 4
...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
398292711

result:

ok 3 lines

Test #2:

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

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
50 7
10505077 30
77009490 31
97377676 9
106894475 20
112906674 30
140889842 5
145744553 28
184647542 6
206787581 48
211622672 23
211919345 12
260870949 39
261086475 6
265087059 48
296273606 36
296390043 40
321922101 37
325179303 31
338015312 3
338573603 46
341925...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
-1

result:

ok 3 lines

Test #3:

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

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
50 50
4319559 2191263
10453240 235644278
11544019 574058501
35862304 881134612
39649181 957419426
42616891 998992313
42729327 172813546
130133254 274807671
147809871 380481904
149345066 80306258
152334016 364814049
163846119 812485977
168657046 339861811
17967877...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
24202306

result:

ok 3 lines

Test #4:

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

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
50 50
103551104 999999999
103922205 1000000000
146704388 999999999
165351223 1000000000
179672569 999999999
194938680 999999999
199044066 999999999
223971817 1000000000
224334563 1000000000
228757784 1000000000
248249037 999999999
249664044 999999999
250222677 99...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
1275295695

result:

ok 3 lines

Test #5:

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

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
50 50
16310772 756454842
29497881 760758038
71929063 692322840
83182685 850840789
83511538 882765837
95542989 982025216
110733238 749254774
116157865 757959984
183719699 726281757
241557767 969467908
259042744 638055299
294315834 558853517
368668699 966242782
388...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
231250468

result:

ok 3 lines

Test #6:

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

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
50 50
3532670 1000000000
15274782 1000000000
50395967 999999999
55575072 1000000000
66664901 999999999
68383610 1000000000
110281177 999999999
120918122 999999999
121190993 999999999
142423270 999999999
152857314 1000000000
171908706 1000000000
175209876 99999999...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
635375230

result:

ok 3 lines

Test #7:

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

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
20 19
8698441 788313703
17422101 870310094
55860139 252495174
56269471 899652654
118490829 742605132
120457215 62401619
147977654 834209593
321415314 210017872
407376178 597384571
425894375 393282297
589528328 25306526
635395496 62229873
668971328 480268035
81966...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
860909725

result:

ok 3 lines

Test #8:

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

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
50 49
4377809 543619393
8186783 368640482
28006115 767021112
35889193 361959270
61306596 95563968
67855675 991060124
141067158 875954520
145080898 799250971
168782787 948025379
182332012 105234579
182976943 445447202
183339055 152963361
191754374 377877413
205284...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
107608863

result:

ok 3 lines

Test #9:

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

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
50 42
0 941822096
1 725252390
2 463478477
3 337860000
4348973 140394368
15220596 91583743
27981049 24172164
77767751 18250653
146624829 29592584
159996263 114097815
163373036 38545104
182955373 11023389
193877913 126345848
195363134 75291644
232072552 400000000
2...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
285137706

result:

ok 3 lines

Test #10:

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

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
50 46
0 881765736
1 599328105
2 483493308
3 246024837
18163406 200000000
52185735 200000000
64929823 200000000
92212418 200000000
115470155 200000000
149239220 200000000
154871554 200000000
165661275 200000000
174557324 200000000
191617860 200000000
222546767 400...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
418163403

result:

ok 3 lines

Test #11:

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

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
50 44
0 923685775
1 839515085
2 706751703
3 660261812
4 564959977
5 423153978
6 349917058
7 179093280
8 136221909
4331907 100000000
45565249 100000000
79319347 100000000
92975003 100000000
98801715 100000000
142728669 152765529
161914671 119590266
168139463 13248...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
204331899

result:

ok 3 lines

Test #12:

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

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
50 43
0 835279180
1 496105644
2 233380054
3 191695009
14122939 23108291
67985796 82236694
81127840 63022271
93500682 55749984
105337996 59354344
128879275 222222222
154490387 222222222
172199087 222222222
199109671 222222222
214161213 222222222
234355486 33333333...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
1135377635

result:

ok 3 lines

Test #13:

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

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
30 22
0 874926175
1 621265150
2 410042551
3 209581046
34886152 6378873
71075403 125346495
83094918 85874534
149532074 150977709
160191094 103354154
170335763 197776050
226602893 397090183
246332791 321962626
279514444 321281286
295468324 272904955
384240358 27527...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
-1

result:

ok 3 lines

Test #14:

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

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
50 49
690832 395162982
6170009 65317613
46696437 614052714
51814428 837046256
82081461 267743291
89946536 183344580
91134489 137687623
100985073 329830388
101979608 341415140
112670194 325794451
119298085 619013984
144698448 22727534
207754757 674196310
220348825...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
8287562567

result:

ok 3 lines

Test #15:

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

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
50 49
24518391 997744992
38043300 830115792
44225039 398816025
74549205 5237910
89111811 944889325
100951530 300198713
135842106 405909202
149544528 611947301
164438047 944706687
177559312 162460600
182816381 718459422
208612610 166998036
223044700 101453119
2391...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
1438794473

result:

ok 3 lines

Subtask #2:

score: 14
Accepted

Test #16:

score: 14
Accepted
time: 536ms
memory: 34584kb

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
10000 100000
11229 379498624
257416 914868002
301444 883725918
329615 283322823
638468 792463292
770046 104694908
879284 802649468
1018107 806188990
1235691 778020663
1610489 361982088
1674779 19735957
1958738 277248707
2020637 306203614
2181162 878070012
2380009...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
40102213

result:

ok 3 lines

Test #17:

score: 0
Accepted
time: 732ms
memory: 69644kb

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
100000 99999
6767 915964540
9076 582892594
18012 616982337
19328 806962096
40403 568844061
45794 685447581
48065 164195160
51950 551966729
52371 77828550
60854 369970353
78912 143177104
106786 270018396
119414 174003769
134565 483764871
136759 679977696
138207 60...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
235935721725

result:

ok 3 lines

Test #18:

score: 0
Accepted
time: 471ms
memory: 59944kb

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
100000 75348
0 999617122
1 990913624
2 985213638
3 980088352
4 975450554
5 973801692
6 965510455
7 963611122
8 958948548
9 950468183
10 945051646
11 942962784
12 935956788
13 930258047
14 925048749
15 923372030
16 915408032
17 911598345
18 907016806
19 901046082
...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
21061938

result:

ok 3 lines

Test #19:

score: 0
Accepted
time: 443ms
memory: 57452kb

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
100000 77572
0 999922935
1 999683391
2 999449498
3 999187907
4 999139335
5 998820536
6 998751588
7 998559991
8 998209176
9 998069443
10 997805535
11 997674772
12 997404832
13 997314784
14 996998548
15 996915622
16 996618237
17 996426247
18 996231838
19 995996193
...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
530789

result:

ok 3 lines

Test #20:

score: 0
Accepted
time: 483ms
memory: 59296kb

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
100000 76041
0 946882834
1 803694138
2 725652406
3 675732327
4 578394713
5 484235783
6 328377097
7 223374859
8 184932990
9 98059238
10 96702457
11 94677232
12 92960860
13 91013636
14 89524101
15 86111836
16 84210747
17 82174337
18 80947534
19 78345217
20 77339154...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
-1

result:

ok 3 lines

Test #21:

score: 0
Accepted
time: 608ms
memory: 36324kb

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
10000 100000
407912 272400171
986928 322294734
1276051 515263193
1287824 958186540
1303638 474955437
1318845 25874375
1649136 431081110
1725030 106945715
1948732 684338366
2148719 229761294
2270356 407567157
2451200 945641792
2638782 374744529
2643858 980786820
2...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
474805552

result:

ok 3 lines

Test #22:

score: 0
Accepted
time: 619ms
memory: 60128kb

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
79999 100000
2567 368509006
6137 106762007
70495 694716552
74677 716061762
75372 321669110
84514 300687579
86371 832230185
88293 995050831
97444 882750646
149935 31349836
160809 351975225
164168 427640928
195044 430742940
225874 467914720
235381 883256729
243291 ...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
-1

result:

ok 3 lines

Test #23:

score: 0
Accepted
time: 855ms
memory: 70668kb

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
99998 100000
25065 152150426
35378 69198993
44341 191343685
50428 74997057
51285 924686239
73300 182100238
98740 282025302
103165 123467121
115780 751219313
130678 442233038
130842 172783049
139362 810025484
144850 193827255
144888 654520680
154202 387192078
1784...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
115075636243

result:

ok 3 lines

Test #24:

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

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
40000 100000
22092 488360029
42786 539645577
50153 970592139
72382 1201661
86018 45454237
172295 532355411
201027 926021146
230248 872081788
253446 116038278
258143 162409568
306047 393118695
346653 233429505
364385 419181188
385733 596524512
421590 737155567
452...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
35198173458

result:

ok 3 lines

Test #25:

score: 0
Accepted
time: 436ms
memory: 55052kb

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
100000 99999
3446 588538249
7031 915929271
14504 64384542
23984 260482285
26386 673764036
28721 473487371
36138 33539506
45807 725320358
59072 810535558
74767 42175064
83646 58048852
112290 932802808
126987 902337282
128966 945379595
139059 351277778
147355 40026...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
14883807493149

result:

ok 3 lines

Test #26:

score: 0
Accepted
time: 828ms
memory: 65152kb

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
100000 99999
7207 792582880
26917 116490216
49651 409708797
56319 889760605
62672 744509111
65852 274556695
94636 843608066
96422 508741377
111433 217235756
117781 28497021
126791 869500649
127985 777246359
128545 837180332
129828 416138109
135933 85836343
147439...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
177349893605

result:

ok 3 lines

Test #27:

score: 0
Accepted
time: 353ms
memory: 50936kb

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
99999 90000
0 999951755
1 999914938
2 999867206
3 999835643
4 999802600
5 999760759
6 999712763
7 999676908
8 999642692
9 999594276
10 999585743
11 999545716
12 999485970
13 999455336
14 999386418
15 999346729
16 999305866
17 999262069
18 999247192
19 999220273
2...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
-1

result:

ok 3 lines

Test #28:

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

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
100000 99999
0 1000000000
1 999999999
2 999999998
3 999999997
4 999999996
5 999999995
6 999999994
7 999999993
8 999999992
9 999999991
10 999999990
11 999999989
12 999999988
13 999999987
14 999999986
15 999999985
16 999999984
17 999999983
18 999999982
19 999999981...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
99996000000009

result:

ok 3 lines

Test #29:

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

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
89871 99969
0 1000000000
1 4542
2 4
3 4
4 6
5 6
6 8
7 8
8 10
9 10
10 12
11 12
12 14
13 14
14 16
15 16
16 18
17 18
18 20
19 20
20 22
21 22
22 24
23 24
24 26
25 26
26 28
27 28
28 30
29 30
30 32
31 32
32 34
33 34
34 36
35 36
36 38
37 38
38 40
39 40
40 42
41 42
42 44...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
17719014635842

result:

ok 3 lines

Test #30:

score: 0
Accepted
time: 161ms
memory: 34588kb

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
87891 96177
0 1000000000
1 499974999
2 999949998
3 2
4 999949998
5 999949998
6 2
7 999949998
8 999949998
9 2
10 999949998
11 999949998
12 2
13 999949998
14 999949998
15 2
16 999949998
17 999949998
18 2
19 999949998
20 999949998
21 2
22 999949998
23 999949998
24 2...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
10841820760896

result:

ok 3 lines

Test #31:

score: 0
Accepted
time: 281ms
memory: 47056kb

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
100000 100000
0 1000000000
1 1
2 1
3 1
4 1
5 1
6 1
7 1
8 1
9 1
10 1
11 1
12 1
13 1
14 1
15 1
16 1
17 1
18 1
19 1
20 1
21 1
22 1
23 1
24 1
25 1
26 1
27 1
28 1
29 1
30 1
31 1
32 1
33 1
34 1
35 1
36 1
37 1
38 1
39 1
40 1
41 1
42 1
43 1
44 1
45 1
46 1
47 1
48 1
49 1
...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
1999900001

result:

ok 3 lines

Test #32:

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

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
4804 4802
13 3803610
895 4889676
2333 4883824
2715 4882665
4580 4879964
5158 4875828
6943 4874074
7927 4872499
8585 4872137
8674 4870845
8990 4869070
12072 4868051
14720 4865693
15110 4864104
15480 4862978
18505 4862427
19328 4859371
19633 4859130
20307 4857451
2...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
11407865292

result:

ok 3 lines

Test #33:

score: 0
Accepted
time: 109ms
memory: 26548kb

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
48004 48002
12 184384229
14510 480116393
46171 480050106
49926 480040984
53357 480034710
55573 479991344
57597 479976308
65300 479948960
70394 479918567
78945 479910242
119781 479893154
124115 479885925
132748 479880370
135811 479848105
136914 479839542
144544 47...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
11536977792949

result:

ok 3 lines

Test #34:

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

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
74999 99997
0 500000000
1 1000000000
2 2
3 1000000000
4 1000000000
5 2
6 1000000000
7 1000000000
8 2
9 1000000000
10 1000000000
11 2
12 1000000000
13 1000000000
14 2
15 1000000000
16 1000000000
17 2
18 1000000000
19 1000000000
20 2
21 1000000000
22 1000000000
23 ...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
25000000025000

result:

ok 3 lines

Test #35:

score: 0
Accepted
time: 115ms
memory: 36016kb

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
100000 99999
0 1000000000
1 10000000
2 10000000
3 10000000
4 10000000
5 10000000
6 10000000
7 10000000
8 10000000
9 10000000
10 10000000
11 10000000
12 10000000
13 10000000
14 10000000
15 10000000
16 10000000
17 10000000
18 10000000
19 10000000
20 10000000
21 100...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
3980099999

result:

ok 3 lines

Test #36:

score: 0
Accepted
time: 365ms
memory: 52084kb

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
99998 99999
0 100000
1 99998
2 99998
3 99996
4 99996
5 99994
6 99994
7 99992
8 99992
9 99990
10 99990
11 99988
12 99988
13 99986
14 99986
15 99984
16 99984
17 99982
18 99982
19 99980
20 99980
21 99978
22 99978
23 99976
24 99976
25 99974
26 99974
27 99972
28 99972...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
299995

result:

ok 3 lines

Test #37:

score: 0
Accepted
time: 139ms
memory: 35688kb

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
92495 99993
0 500000000
1 1000000000
2 2
3 1000000000
4 1000000000
5 2
6 1000000000
7 1000000000
8 2
9 1000000000
10 1000000000
11 2
12 1000000000
13 1000000000
14 2
15 1000000000
16 1000000000
17 2
18 1000000000
19 1000000000
20 2
21 1000000000
22 1000000000
23 ...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
7523880097480

result:

ok 3 lines

Test #38:

score: 0
Accepted
time: 109ms
memory: 34292kb

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
86602 97795
0 1000000000
1 10000000
2 10000000
3 10000000
4 1000000000
5 1000000000
6 10000000
7 10000000
8 10000000
9 1000000000
10 500000000
11 1000000000
12 2
13 1000000000
14 1000000000
15 2
16 1000000000
17 500000000
18 10
19 4
20 4
21 6
22 6
23 8
24 8
25 10...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
10386060102603

result:

ok 3 lines

Subtask #3:

score: 15
Accepted

Test #39:

score: 15
Accepted
time: 40ms
memory: 10048kb

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
10000 48653
27965 6
121607 6
131872 6
261202 6
290936 6
380545 6
407583 6
409883 6
470540 6
755516 6
821706 6
845827 6
914542 6
987977 6
1010549 6
1146589 6
1176047 6
1195879 6
1214878 6
1235946 6
1281972 6
1310257 6
1370770 6
1551075 6
1610014 6
1997123 6
202836...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
999925543

result:

ok 3 lines

Test #40:

score: 0
Accepted
time: 685ms
memory: 29568kb

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
1000 100000
887346 949882323
1040812 949882323
1280407 949882323
1549934 949882323
1883802 949882323
5273313 949882323
5392682 949882323
5743083 949882323
6743220 949882323
7179361 949882323
7405859 949882323
9514529 949882323
10892816 949882323
13171876 94988232...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
1030288399

result:

ok 3 lines

Test #41:

score: 0
Accepted
time: 736ms
memory: 32620kb

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
10000 100000
11899 185799916
20674 185799916
394409 185799916
444685 185799916
526778 185799916
749676 185799916
1045417 185799916
1189710 185799916
1202278 185799916
1220302 185799916
1297704 185799916
1462015 185799916
1498037 185799916
1604925 185799916
174723...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
1050298835

result:

ok 3 lines

Test #42:

score: 0
Accepted
time: 1089ms
memory: 62416kb

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
100000 100000
8856 653608935
17186 653608935
26217 653608935
39674 653608935
52575 653608935
57626 653608935
72105 653608935
87153 653608935
107771 653608935
112498 653608935
122109 653608935
125104 653608935
131321 653608935
139413 653608935
146450 653608935
159...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
1181301098

result:

ok 3 lines

Test #43:

score: 0
Accepted
time: 1214ms
memory: 66496kb

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
100000 100000
1757 803315633
4173 803315633
12755 803315633
67154 803315633
71406 803315633
81973 803315633
93649 803315633
108194 803315633
113858 803315633
115917 803315633
118602 803315633
119022 803315633
124865 803315633
131764 803315633
134913 803315633
144...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
2270087051

result:

ok 3 lines

Test #44:

score: 0
Accepted
time: 1130ms
memory: 62944kb

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
100000 100000
19446 924188635
20989 924188635
27508 924188635
40055 924188635
47888 924188635
55603 924188635
70255 924188635
76764 924188635
78864 924188635
79237 924188635
82970 924188635
83003 924188635
103877 924188635
120437 924188635
126393 924188635
127452...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
1226989743

result:

ok 3 lines

Test #45:

score: 0
Accepted
time: 530ms
memory: 48936kb

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
99999 50999
1015 439863710
10577 439863710
12763 439863710
14336 439863710
29405 439863710
46654 439863710
52147 439863710
72031 439863710
77685 439863710
82293 439863710
86007 439863710
116132 439863710
119369 439863710
120771 439863710
142542 439863710
143419 4...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
1746945354

result:

ok 3 lines

Test #46:

score: 0
Accepted
time: 298ms
memory: 45496kb

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
100000 99999
1099 286352584
15104 286352584
34418 286352584
35262 286352584
48166 286352584
55932 286352584
60763 286352584
61729 286352584
66239 286352584
88016 286352584
93547 286352584
149257 286352584
157995 286352584
165424 286352584
173294 286352584
174502 ...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
9524259954763

result:

ok 3 lines

Test #47:

score: 0
Accepted
time: 977ms
memory: 61836kb

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
100000 99999
18627 525674613
24449 525674613
51272 525674613
56603 525674613
57778 525674613
58476 525674613
61103 525674613
90377 525674613
90597 525674613
118831 525674613
120377 525674613
121092 525674613
123081 525674613
136709 525674613
171660 525674613
1720...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
1918856187

result:

ok 3 lines

Test #48:

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

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
100000 100000
0 1000000000
1 1000000000
2 1000000000
3 1000000000
4 1000000000
5 1000000000
6 1000000000
7 1000000000
8 1000000000
9 1000000000
10 1000000000
11 1000000000
12 1000000000
13 1000000000
14 1000000000
15 1000000000
16 1000000000
17 1000000000
18 1000...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
1000100001

result:

ok 3 lines

Test #49:

score: 0
Accepted
time: 15ms
memory: 16052kb

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
50000 100
10129 85863
29357 85863
84171 85863
100825 85863
155298 85863
162657 85863
164370 85863
197166 85863
217236 85863
270142 85863
273552 85863
282903 85863
333071 85863
341891 85863
358214 85863
364831 85863
367550 85863
401049 85863
421150 85863
484655 85...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
-1

result:

ok 3 lines

Subtask #4:

score: 18
Accepted

Dependency #3:

100%
Accepted

Test #50:

score: 18
Accepted
time: 775ms
memory: 33568kb

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
10000 100000
85708 635716805
137856 782654777
300212 601520007
424007 331603920
444374 197669227
498795 451332790
520141 901786386
544074 826726657
572687 816276091
706839 784377842
822300 825067174
979208 396562226
983962 347275642
1088239 722472798
1203826 4708...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
1011030757

result:

ok 3 lines

Test #51:

score: 0
Accepted
time: 1092ms
memory: 71428kb

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
100000 100000
8420 422104786
25892 276923376
26577 120611256
34397 661349269
82622 800985835
97419 409798292
106577 785396852
108378 821217115
108393 296921472
154535 808204379
155990 825385132
156856 391778795
160182 732540546
179404 74557037
182648 139948098
18...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
-1

result:

ok 3 lines

Test #52:

score: 0
Accepted
time: 1606ms
memory: 76476kb

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
100000 100000
30986 60708724
31349 791181874
35482 597992204
45649 905715409
46103 104488139
57099 850824628
83922 843682062
89196 191874450
97287 700134288
97888 902606970
101687 257269996
102910 835241203
106445 313508960
118423 595161956
133298 532976083
13740...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
1076234540

result:

ok 3 lines

Test #53:

score: 0
Accepted
time: 564ms
memory: 51808kb

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
100000 100000
13310 1000000000
19225 999999999
49638 1000000000
50479 999999999
59530 1000000000
61762 1000000000
78737 999999999
104723 1000000000
117293 999999999
123868 999999999
170329 1000000000
173410 999999999
176495 999999999
179443 999999999
252706 10000...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
1701066833

result:

ok 3 lines

Test #54:

score: 0
Accepted
time: 1066ms
memory: 67204kb

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
100000 100000
8354 902446637
8710 959931073
10913 860501508
25773 696372251
28306 626637177
39205 516724633
59771 933173231
61667 724399583
65991 716778181
84774 813886795
93498 571646374
102348 936235883
108586 705066271
119767 991492783
126702 883191153
144847 ...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
1999985558

result:

ok 3 lines

Test #55:

score: 0
Accepted
time: 1105ms
memory: 68944kb

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
100000 100000
1878 610595898
19170 943265944
24354 812597523
29444 746755930
36397 808176346
43429 763684579
44678 828708315
51920 941786287
104605 786967781
111068 909873462
114269 787532011
122805 771610548
133053 874779244
169267 846299098
174131 681603651
193...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
2000644419

result:

ok 3 lines

Test #56:

score: 0
Accepted
time: 534ms
memory: 51856kb

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
100000 100000
13310 1000000000
19225 999999999
49638 1000000000
50479 999999999
59530 1000000000
61762 1000000000
78737 999999999
104723 1000000000
117293 999999999
123868 999999999
170329 1000000000
173410 999999999
176495 999999999
179443 999999999
252706 10000...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
1701066833

result:

ok 3 lines

Test #57:

score: 0
Accepted
time: 1078ms
memory: 66960kb

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
100000 100000
15413 909677945
46312 908324146
102652 619897425
115209 975576284
130078 969556372
131823 815558416
135253 841071726
135805 710604873
150739 929624025
170638 800737899
191198 995407187
197182 555312915
205521 675573182
209414 656743672
210498 810572...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
-1

result:

ok 3 lines

Test #58:

score: 0
Accepted
time: 963ms
memory: 60176kb

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
100000 50000
12000 60866324
12793 95766463
15298 942112860
22306 69295188
25197 753907540
29800 464525288
39297 792119700
45481 666316088
57897 934496697
60007 389142602
65692 145069249
75067 440387557
76064 767353496
89502 505492547
101811 619671026
101931 19829...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
1000914512

result:

ok 3 lines

Test #59:

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

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
100000 1000
1275 20876033
1673 246410514
2330 8371526
4445 940590571
9068 637957082
27474 852908591
36789 644962113
43797 212286275
50683 198186813
51625 245049141
66117 353409723
68834 478533444
97973 19009007
103332 401974949
106852 681444541
134521 755147652
1...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
1018132020

result:

ok 3 lines

Test #60:

score: 0
Accepted
time: 579ms
memory: 60764kb

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
100000 84032
0 990963011
1 989786346
2 970655920
3 966648636
4 954464281
5 943021781
6 934998491
7 921868604
8 914949050
9 907198791
10 892540064
11 880084735
12 879557306
13 866440990
14 853113273
15 842758925
16 830720828
17 821689362
18 810233874
19 800733606
...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
2981924921

result:

ok 3 lines

Test #61:

score: 0
Accepted
time: 493ms
memory: 58448kb

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
100000 88583
0 999846225
1 998907803
2 996998517
3 996294155
4 995373709
5 994002983
6 993817061
7 992294117
8 991043511
9 990320273
10 989193775
11 988299906
12 987180737
13 986127134
14 985360186
15 984476052
16 983039738
17 982053153
18 981143911
19 980458063
...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
3890901336

result:

ok 3 lines

Test #62:

score: 0
Accepted
time: 374ms
memory: 53488kb

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
100000 90332
0 999914455
1 999845066
2 999697630
3 999615925
4 999544984
5 999392921
6 999322803
7 999201780
8 999102561
9 999011628
10 998928155
11 998879522
12 998727575
13 998600366
14 998567333
15 998494325
16 998321259
17 998226632
18 998127610
19 998009418
...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
3420962462

result:

ok 3 lines

Test #63:

score: 0
Accepted
time: 495ms
memory: 60600kb

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
100000 83983
0 987072789
1 963173799
2 940537388
3 936274850
4 905833004
5 891884438
6 872306755
7 841833978
8 823386864
9 818752038
10 796395763
11 765002498
12 748311020
13 735854883
14 713962125
15 682833114
16 663146595
17 652684072
18 635560306
19 603316288
...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
2999209740

result:

ok 3 lines

Test #64:

score: 0
Accepted
time: 308ms
memory: 52012kb

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
99999 90000
0 999947032
1 999916611
2 999896759
3 999843297
4 999799425
5 999777155
6 999739807
7 999708411
8 999643728
9 999607735
10 999559106
11 999510173
12 999485108
13 999447153
14 999398418
15 999356906
16 999317615
17 999300762
18 999243094
19 999187444
2...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
-1

result:

ok 3 lines

Test #65:

score: 0
Accepted
time: 1585ms
memory: 76068kb

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
100000 100000
3407 740436898
16348 165082581
31749 372273430
46878 143342612
53535 318823498
64364 168487211
67917 794920245
73129 703511777
82468 123668891
98743 448711444
115671 323450293
119926 380518142
123481 824497936
123870 343399609
135144 931062196
16425...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
1146380736

result:

ok 3 lines

Test #66:

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

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
99998 100000
3643 468896252
17525 719746783
30434 767261047
73197 148611110
92816 857615263
126542 139751853
127506 542890221
163744 858893660
170350 430264299
172594 366078838
196961 873263060
198735 540539353
206344 781454716
209757 145908612
219052 19247213
24...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
-1

result:

ok 3 lines

Test #67:

score: 0
Accepted
time: 1498ms
memory: 74336kb

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
100000 100000
2849 36780892
33987 686798550
35280 847126426
58007 757338928
76361 170118885
103274 137132454
116944 951944120
149935 519062036
150290 811964015
157181 613397051
168444 817858589
175501 995611827
176569 497290909
186918 725246240
187481 872812006
2...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
1031409377

result:

ok 3 lines

Test #68:

score: 0
Accepted
time: 895ms
memory: 60360kb

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
99999 50999
2062 601636857
9304 954536536
10324 9236024
19756 994804184
20576 713921363
22669 411490882
28778 389129134
43243 149136195
48108 110309589
48761 412798396
80369 587733916
82044 565702273
90543 268496518
102598 198715741
102714 635199594
110062 652776...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
1398986573

result:

ok 3 lines

Test #69:

score: 0
Accepted
time: 1486ms
memory: 74412kb

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
100000 99999
14806 999203168
17694 884129554
32539 913290952
34780 976702059
79914 921009767
86954 808237801
87044 306007238
100918 49237594
109802 379312610
123548 671865376
129674 705294658
141272 316598635
151459 408724299
157854 225833130
193985 999718355
198...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
1083455268

result:

ok 3 lines

Test #70:

score: 0
Accepted
time: 206ms
memory: 42164kb

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
87499 99997
0 1000000000
1 1000000000
2 1000000000
3 1000000000
4 1000000000
5 1000000000
6 1000000000
7 1000000000
8 1000000000
9 1000000000
10 1000000000
11 1000000000
12 1000000000
13 1000000000
14 1000000000
15 1000000000
16 1000000000
17 1000000000
18 100000...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
12501000062500

result:

ok 3 lines

Test #71:

score: 0
Accepted
time: 207ms
memory: 45240kb

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
100000 99999
0 1000000000
1 1000000000
2 1000000000
3 1000000000
4 1000000000
5 1000000000
6 1000000000
7 1000000000
8 1000000000
9 1000000000
10 1000000000
11 1000000000
12 1000000000
13 1000000000
14 1000000000
15 1000000000
16 1000000000
17 1000000000
18 10000...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
4980099999

result:

ok 3 lines

Test #72:

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

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
99998 99999
0 1000000000
1 1000000000
2 1000000000
3 1000000000
4 1000000000
5 1000000000
6 1000000000
7 1000000000
8 1000000000
9 1000000000
10 1000000000
11 1000000000
12 1000000000
13 1000000000
14 1000000000
15 1000000000
16 1000000000
17 1000000000
18 100000...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
1000199995

result:

ok 3 lines

Test #73:

score: 0
Accepted
time: 378ms
memory: 45712kb

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
94996 99993
0 1000000000
1 10000000
2 10000000
3 10000000
4 10000000
5 10000000
6 10000000
7 10000000
8 10000000
9 10000000
10 10000000
11 10000000
12 10000000
13 10000000
14 10000000
15 10000000
16 10000000
17 10000000
18 10000000
19 10000000
20 10000000
21 1000...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
5014365330041

result:

ok 3 lines

Test #74:

score: 0
Accepted
time: 218ms
memory: 40676kb

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
91996 98691
0 1000000000
1 10000000
2 10000000
3 10000000
4 1000000000
5 1000000000
6 10000000
7 10000000
8 10000000
9 1000000000
10 1000000000
11 10000000
12 10000000
13 10000000
14 1000000000
15 1000000000
16 10000000
17 10000000
18 10000000
19 1000000000
20 10...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
8662261036489

result:

ok 3 lines

Test #75:

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

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
74999 99997
0 500000000
1 1000000000
2 2
3 1000000000
4 1000000000
5 2
6 1000000000
7 1000000000
8 2
9 1000000000
10 1000000000
11 2
12 1000000000
13 1000000000
14 2
15 1000000000
16 1000000000
17 2
18 1000000000
19 1000000000
20 2
21 1000000000
22 1000000000
23 ...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
25000000025000

result:

ok 3 lines

Test #76:

score: 0
Accepted
time: 121ms
memory: 36088kb

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
100000 99999
0 1000000000
1 10000000
2 10000000
3 10000000
4 10000000
5 10000000
6 10000000
7 10000000
8 10000000
9 10000000
10 10000000
11 10000000
12 10000000
13 10000000
14 10000000
15 10000000
16 10000000
17 10000000
18 10000000
19 10000000
20 10000000
21 100...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
3980099999

result:

ok 3 lines

Test #77:

score: 0
Accepted
time: 361ms
memory: 52116kb

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
99998 99999
0 100000
1 99998
2 99998
3 99996
4 99996
5 99994
6 99994
7 99992
8 99992
9 99990
10 99990
11 99988
12 99988
13 99986
14 99986
15 99984
16 99984
17 99982
18 99982
19 99980
20 99980
21 99978
22 99978
23 99976
24 99976
25 99974
26 99974
27 99972
28 99972...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
299995

result:

ok 3 lines

Test #78:

score: 0
Accepted
time: 133ms
memory: 35668kb

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
92495 99993
0 500000000
1 1000000000
2 2
3 1000000000
4 1000000000
5 2
6 1000000000
7 1000000000
8 2
9 1000000000
10 1000000000
11 2
12 1000000000
13 1000000000
14 2
15 1000000000
16 1000000000
17 2
18 1000000000
19 1000000000
20 2
21 1000000000
22 1000000000
23 ...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
7523880097480

result:

ok 3 lines

Test #79:

score: 0
Accepted
time: 114ms
memory: 34308kb

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
86602 97795
0 1000000000
1 10000000
2 10000000
3 10000000
4 1000000000
5 1000000000
6 10000000
7 10000000
8 10000000
9 1000000000
10 500000000
11 1000000000
12 2
13 1000000000
14 1000000000
15 2
16 1000000000
17 500000000
18 10
19 4
20 4
21 6
22 6
23 8
24 8
25 10...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
10386060102603

result:

ok 3 lines

Subtask #5:

score: 43
Accepted

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

100%
Accepted

Dependency #4:

100%
Accepted

Test #80:

score: 43
Accepted
time: 40ms
memory: 9972kb

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
10000 38464
10691 10
85715 9
277472 6
345957 7
512794 4
842750 1
847549 8
947690 7
948052 7
969388 10
1012942 2
1174245 2
1224525 1
1234345 3
1583781 6
1668009 10
1732807 7
1757181 9
1927260 2
2097189 4
2118992 10
2135976 6
2198854 4
2297691 4
2614530 1
2633327 1...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
610403421

result:

ok 3 lines

Test #81:

score: 0
Accepted
time: 894ms
memory: 38732kb

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
10000 100000
108073 77151838
114842 610725818
208582 994864058
211584 839667691
238833 302376943
474778 878639150
716887 723999986
887396 190324369
910075 209868181
1073820 996479484
1080894 44653835
1156296 884462413
1199415 394815147
1356254 806020804
1386587 7...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
486386017

result:

ok 3 lines

Test #82:

score: 0
Accepted
time: 1736ms
memory: 83812kb

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
100000 100000
3970 480822291
15517 384507516
24253 77878694
25036 445725381
27430 997761151
28079 559906335
30855 127455433
47695 225566993
60403 77761446
69221 630788092
71593 385221131
89254 307060898
101276 424866791
105640 426656748
116952 330143626
117343 41...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
747946633

result:

ok 3 lines

Test #83:

score: 0
Accepted
time: 132ms
memory: 34996kb

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
100000 10000
15001 1000000000
34966 999999999
37223 1000000000
42048 1000000000
53777 1000000000
59208 1000000000
63605 1000000000
64344 999999999
83354 999999999
90436 999999999
100324 999999999
102358 1000000000
107064 1000000000
107246 1000000000
119524 999999...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
165319279

result:

ok 3 lines

Test #84:

score: 0
Accepted
time: 415ms
memory: 48112kb

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
100000 10000
2220 785605025
23500 725457383
34839 846146799
35199 533769472
37352 716427609
72462 947089821
75611 656972576
92954 686929005
104962 870879626
109058 651348675
125374 581963257
134494 980371920
143713 674919992
150316 604661525
163746 585845272
1668...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
89820392

result:

ok 3 lines

Test #85:

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

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
100000 10000
15001 1000000000
34966 999999999
37223 1000000000
42048 1000000000
53777 1000000000
59208 1000000000
63605 1000000000
64344 999999999
83354 999999999
90436 999999999
100324 999999999
102358 1000000000
107064 1000000000
107246 1000000000
119524 999999...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
165319279

result:

ok 3 lines

Test #86:

score: 0
Accepted
time: 18ms
memory: 7576kb

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
10000 10068
164312 5
200359 5
239959 2
241344 3
283417 8
287737 9
297544 10
360518 7
387241 8
446944 9
469035 2
477100 8
546405 10
569828 10
591489 9
660410 5
674287 2
944089 7
1112103 2
1355561 6
1588464 9
1731257 3
1784456 10
1893079 10
2007300 7
2348822 1
2437...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
701676886

result:

ok 3 lines

Test #87:

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

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
1000 100
821055 362864331
1534303 79550452
2549102 354381653
3084020 17154648
6162575 279487714
6865030 193977704
6996733 428924122
8784914 865246953
9116923 586150516
9469128 126564641
11300801 364470891
11573655 634807212
12483644 886823920
13440850 407612815
1...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
21346009

result:

ok 3 lines

Test #88:

score: 0
Accepted
time: 57ms
memory: 8608kb

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
10000 3433
99512 395248074
298498 850792835
347287 964553251
392051 955470690
669822 582665031
795072 121452307
825945 727409722
940830 955915701
945644 765655157
951552 281107906
1168792 307615430
1190649 572778645
1326079 758438004
1436671 738810411
1493758 559...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
313331906

result:

ok 3 lines

Test #89:

score: 0
Accepted
time: 872ms
memory: 57544kb

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
100000 33433
5822 752943890
45080 888822040
47687 545535168
60309 998621192
60681 740388807
62234 931427109
64462 494832525
91688 962193046
101762 483716273
107241 134055595
143383 329065788
156145 45376308
167294 437337621
170806 309359632
198688 305482170
20749...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
156916701

result:

ok 3 lines

Test #90:

score: 0
Accepted
time: 504ms
memory: 45780kb

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
100000 993
34136 554329839
38141 990046138
62538 624453881
72830 649188303
76799 62212530
83017 148500005
96036 468827552
107383 224682720
145819 591355388
160117 449464557
182826 928646512
185247 446997607
207885 611063586
217198 569468732
241789 160718832
24218...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
261535133

result:

ok 3 lines

Test #91:

score: 0
Accepted
time: 635ms
memory: 62228kb

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
100000 88023
0 990001931
1 981991036
2 973066902
3 961097149
4 954821438
5 947997732
6 933663767
7 920461786
8 914723516
9 906388128
10 893377142
11 883531501
12 873538022
13 860758358
14 851132995
15 841137318
16 834648125
17 822293908
18 816813722
19 801260510
...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
24808328

result:

ok 3 lines

Test #92:

score: 0
Accepted
time: 509ms
memory: 59312kb

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
100000 89318
0 999428179
1 998558023
2 997041770
3 996106394
4 995392927
5 994441276
6 993012377
7 992710296
8 991076052
9 990756486
10 989070223
11 988168539
12 987337305
13 986247543
14 985111808
15 984045975
16 983068008
17 982061790
18 981124639
19 980501931
...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
3902268

result:

ok 3 lines

Test #93:

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

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
100000 90172
0 999912804
1 999823376
2 999715659
3 999608841
4 999508390
5 999434263
6 999300422
7 999263685
8 999105134
9 999050817
10 998957432
11 998861598
12 998727221
13 998680126
14 998509627
15 998422596
16 998389137
17 998204030
18 998113785
19 998002035
...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
333100

result:

ok 3 lines

Test #94:

score: 0
Accepted
time: 524ms
memory: 61200kb

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
100000 83869
0 982765133
1 968661978
2 952021751
3 920089801
4 904020942
5 892946207
6 864727711
7 855475576
8 829812565
9 818249547
10 792411513
11 771778479
12 751890285
13 728122472
14 701734785
15 694196549
16 678660758
17 656535756
18 627213680
19 615695264
...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
92843031

result:

ok 3 lines

Test #95:

score: 0
Accepted
time: 1926ms
memory: 84644kb

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
100000 100000
657 111325312
1315 204528837
31527 358285130
55247 741333918
58441 810475052
61805 158255854
65159 55336272
71734 997677783
88972 920044359
102777 463771222
103026 119532092
117168 740954004
132698 278355564
144047 762613116
144141 898408405
148118 ...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
171859494

result:

ok 3 lines

Test #96:

score: 0
Accepted
time: 1528ms
memory: 79684kb

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
99998 100000
1603 675334016
8800 722736243
40335 41005442
49599 879906396
55962 940946774
56291 760187137
57491 472484335
66737 839904819
69021 792191340
71314 983425882
77398 299707461
82009 238091210
93406 193831361
100328 113660506
107801 744613291
114337 2887...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
542427669

result:

ok 3 lines

Test #97:

score: 0
Accepted
time: 1731ms
memory: 78388kb

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
100000 100000
15428 709425157
25995 510669708
45734 25423116
48043 917732117
49241 436735920
51690 640061355
59554 510950314
69045 100025530
81131 841312805
87310 410713310
98623 316618438
108232 614254726
123608 205367019
124244 348447444
126365 13979446
131499 ...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
74285763

result:

ok 3 lines

Test #98:

score: 0
Accepted
time: 930ms
memory: 62308kb

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
99999 50999
10653 726640682
14373 611352548
26456 788301869
27290 7467298
31672 39660924
45689 354963842
71232 156361748
79917 269533954
94686 743115074
100403 335350479
108287 159262001
108327 266230523
117268 100098500
122566 54418796
123264 783103142
125121 32...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
205682769

result:

ok 3 lines

Test #99:

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

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
87500 99998
0 1000000000
1 999999999
2 999999999
3 999999999
4 999999999
5 999999999
6 999999999
7 999999999
8 999999999
9 999999999
10 999999999
11 999999999
12 999999999
13 999999999
14 999999999
15 999999999
16 999999999
17 999999999
18 999999999
19 999999999
...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
12503000124995

result:

ok 3 lines

Test #100:

score: 0
Accepted
time: 204ms
memory: 44904kb

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
100000 99999
0 1000000000
1 999999999
2 999999999
3 999999999
4 999999999
5 999999999
6 999999999
7 999999999
8 999999999
9 999999999
10 999999999
11 999999999
12 999999999
13 999999999
14 999999999
15 999999999
16 999999999
17 999999999
18 999999999
19 999999999...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
6980199991

result:

ok 3 lines

Test #101:

score: 0
Accepted
time: 315ms
memory: 49104kb

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
99997 99998
0 1000000000
1 49998
2 49996
3 49996
4 49994
5 49994
6 49992
7 49992
8 49990
9 49990
10 49988
11 49988
12 49986
13 49986
14 49984
15 49984
16 49982
17 49982
18 49980
19 49980
20 49978
21 49978
22 49976
23 49976
24 49974
25 49974
26 49972
27 49972
28 4...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
3000299981

result:

ok 3 lines

Test #102:

score: 0
Accepted
time: 253ms
memory: 46204kb

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
100000 99999
0 1000000000
1 999999999
2 999999999
3 999999999
4 999999999
5 999999999
6 999999999
7 999999999
8 999999999
9 999999999
10 999999999
11 999999999
12 999999999
13 999999999
14 999999999
15 999999999
16 999999999
17 999999999
18 999999999
19 999999999...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
50001000124998

result:

ok 3 lines

Test #103:

score: 0
Accepted
time: 291ms
memory: 45756kb

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
99997 99998
0 1000000000
1 49998
2 49996
3 49996
4 49994
5 49994
6 49992
7 49992
8 49990
9 49990
10 49988
11 49988
12 49986
13 49986
14 49984
15 49984
16 49982
17 49982
18 49980
19 49980
20 49978
21 49978
22 49976
23 49976
24 49974
25 49974
26 49972
27 49972
28 4...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
49998000174992

result:

ok 3 lines

Test #104:

score: 0
Accepted
time: 75ms
memory: 9576kb

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
10000 8000
5 8236361
18651 4829556
25594 4813782
51107 4803206
52097 4760899
55327 4758146
55855 4745256
71256 4712745
86625 4686573
100959 4662414
107099 4648327
122361 4630904
129603 4629707
145427 4624063
162547 4623315
170795 4614181
171940 4598274
172614 458...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
2666194131

result:

ok 3 lines

Test #105:

score: 0
Accepted
time: 1247ms
memory: 65620kb

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
100000 80000
12 878658923
3322 38985832
5447 38971034
10563 38966869
13910 38945092
15463 38928931
31278 38916181
35103 38911289
36944 38909167
44777 38895061
45581 38879611
53929 38854367
54155 38842457
55111 38836069
77017 38811244
84182 38786442
94611 38766809...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
162587566393

result:

ok 3 lines

Test #106:

score: 0
Accepted
time: 984ms
memory: 73916kb

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
100000 99997
0 989982623
1 959998182
2 954056232
3 920850556
4 905608002
5 895483825
6 860998343
7 843456536
8 828497503
9 801557424
10 796356171
11 765223769
12 742953101
13 720081320
14 702923388
15 681200148
16 667497808
17 641141811
18 621991875
19 605018831
...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
-1

result:

ok 3 lines

Test #107:

score: 0
Accepted
time: 907ms
memory: 75112kb

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
100000 100000
0 980463927
1 968365959
2 943588590
3 920764307
4 904035446
5 880081053
6 873863667
7 852174309
8 820567377
9 803854896
10 781087259
11 771911557
12 740874732
13 720393320
14 700402273
15 687352052
16 662443083
17 645556153
18 628505966
19 609706723...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
-1

result:

ok 3 lines

Test #108:

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

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
95199 99967
0 1000000000
1 4540
2 4540
3 4538
4 4538
5 4536
6 4536
7 4534
8 4534
9 4532
10 4532
11 4530
12 4530
13 4528
14 4528
15 4526
16 4526
17 4524
18 4524
19 4522
20 4522
21 4520
22 4520
23 4518
24 4518
25 4516
26 4516
27 4514
28 4514
29 4512
30 4512
31 4510...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
14352541613102

result:

ok 3 lines

Test #109:

score: 0
Accepted
time: 308ms
memory: 42660kb

input:

447adec2-e0e7-4579-a2da-fed58fa3393e
92413 97538
0 1000000000
1 52
2 4
3 4
4 6
5 6
6 8
7 8
8 10
9 10
10 12
11 12
12 14
13 14
14 16
15 16
16 18
17 18
18 20
19 20
20 22
21 22
22 24
23 24
24 26
25 26
26 28
27 28
28 30
29 30
30 32
31 32
32 34
33 34
34 36
35 36
36 38
37 38
38 40
39 40
40 42
41 42
42 44
4...

output:

d99f6469-b674-4a96-9c39-7bc072e22a4f
OK
8877715689223

result:

ok 3 lines

Extra Test:

score: 0
Extra Test Passed