QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#880028#8074. Multiply Then PlusMirasycleAC ✓2063ms285268kbC++143.0kb2025-02-02 20:20:472025-02-02 20:20:48

Judging History

This is the latest submission verdict.

  • [2025-02-02 20:20:48]
  • Judged
  • Verdict: AC
  • Time: 2063ms
  • Memory: 285268kb
  • [2025-02-02 20:20:47]
  • Submitted

answer

#include<bits/stdc++.h>
#define pb emplace_back
#define fi first
#define se second
#define mp make_pair
#define ls (p<<1)
#define rs (p<<1|1)
#define mid (l+r>>1)
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<int,pair<int,int> > pii;
const int maxn=5e5+10;
int n,m,qc=0; ll ans[maxn];
struct Query{
	int x,l,r,id,tim;
	bool operator < (const Query &rhs) const { return x<rhs.x; }
}; vector<Query> q; int val[maxn][3],t;
struct Change{
	int a,b,l,r,id;
}a[maxn<<1];
struct node{
	int x,y;
	node operator - (const node& rhs){ return {x-rhs.x,y-rhs.y}; }
	ll operator * (const node &rhs){ return 1ll*x*rhs.y-1ll*y*rhs.x; }
	ll val(int k){ return 1ll*k*x+y; }
};
bool cmp(node s1,node s2){ return s1.x==s2.x?s1.y<s2.y:s1.x<s2.x; }
int cur[maxn],tot=0;
struct SegmentTree{
	vector<node> s[maxn<<2]; int to[maxn<<2];
	void build(int p,int l,int r){
		to[p]=0;
		if(l==r){ s[p].clear(); s[p].pb((node){val[l][1],val[l][2]}); return ; }
		build(ls,l,mid); build(rs,mid+1,r);
		s[p].resize(s[ls].size()+s[rs].size());
		merge(s[ls].begin(),s[ls].end(),s[rs].begin(),s[rs].end(),s[p].begin(),cmp);
		int top=-1;
		for(auto z:s[p]){
			while(top>=1&&(s[p][top]-s[p][top-1])*(z-s[p][top-1])>=0) top--;
			s[p][++top]=z;
		}
		s[p].resize(top+1);
	}
	ll query(int p,int l,int r,int ql,int qr,int k){
		if(val[r][0]<ql||val[l][0]>qr) return 0;
		if(ql<=val[l][0]&&val[r][0]<=qr){
			while(to[p]+1<(int)s[p].size()){
				if(s[p][to[p]].val(k)<=s[p][to[p]+1].val(k)) to[p]++;
				else break;
			}
			return s[p][to[p]].val(k);
		}
		ll res=0;
		res=max(res,query(ls,l,mid,ql,qr,k));
		res=max(res,query(rs,mid+1,r,ql,qr,k));
		return res;
	}
}seg;
namespace DS{
	vector<pii > op[maxn<<2];
	void modify(int p,int l,int r,int ql,int qr,pii z){
		if(ql<=l&&r<=qr){ op[p].pb(z); return ; }
		if(ql<=mid) modify(ls,l,mid,ql,qr,z);
		if(qr>mid) modify(rs,mid+1,r,ql,qr,z);
	}
	void query(int p,int l,int r,vector<Query> vec){
		if(vec.empty()) return ;
		if(op[p].size()){
			sort(op[p].begin(),op[p].end()); t=0;
			for(auto z:op[p]) val[++t][0]=z.fi,val[t][1]=z.se.fi,val[t][2]=z.se.se;
			seg.build(1,1,t);
			sort(vec.begin(),vec.end());
			for(auto z:vec)
				ans[z.id]=max(ans[z.id],seg.query(1,1,t,z.l,z.r,z.x));
		}
		if(l==r) return ; q.clear(); 
		for(auto z:vec)
			if(z.tim<=mid) q.pb(z);
		query(ls,l,mid,q); q.clear();
		for(auto z:vec)
			if(z.tim>mid) q.pb(z);
		query(rs,mid+1,r,q);
	}
}
int main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin>>n>>m; tot=n;
	for(int i=1;i<=n;i++){
		int A,B; cin>>A>>B;
		a[i]={A,B,1,m,i}; cur[i]=i;
	}
	for(int i=1;i<=m;i++){
		int op,k,x,y;
		cin>>op>>k>>x>>y;
		if(op==1){
			a[cur[k]].r=i-1;
			cur[k]=++tot; a[tot]={x,y,i,m,k};
		}else q.pb((Query){k,x,y,++qc,i});
	}
	for(int i=1;i<=tot;i++)
		if(a[i].l<=a[i].r) DS::modify(1,1,m,a[i].l,a[i].r,mp(a[i].id,mp(a[i].a,a[i].b)));
	DS::query(1,1,m,q);
	for(int i=1;i<=qc;i++) cout<<ans[i]<<"\n";
	return 0;
}

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

詳細信息

Test #1:

score: 100
Accepted
time: 18ms
memory: 105780kb

input:

3 5
2 3
1 5
3 1
2 1 1 3
2 3 1 2
1 3 1 1
2 3 3 3
2 2 1 3

output:

6
9
4
7

result:

ok 4 lines

Test #2:

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

input:

1 1
2 3
2 1 1 1

output:

5

result:

ok single line: '5'

Test #3:

score: 0
Accepted
time: 2063ms
memory: 246296kb

input:

500000 500000
791081793 64517634
63854499 862465815
176217868 269277485
771263429 404780756
245029288 14378702
34910864 161492952
585187086 458118344
482234206 288599768
702175385 765411906
210811947 470958349
996540296 51490854
269173275 127623858
117329791 70500259
30220786 362448265
502753543 587...

output:

90673144893901202
168977598037656727
369057312490922371
27069672474626964
515861257880185716
363463806608012796
231016940250228762
599812787259299741
27057837598661678
555410956991919756
705068069976524824
811896201592615375
585493454790584176
590320139495565318
183884030832072102
208985178365859030...

result:

ok 247193 lines

Test #4:

score: 0
Accepted
time: 1983ms
memory: 243332kb

input:

500000 500000
292679466 68159880
236494044 542881948
11429094 411412642
799738492 373886051
137137671 901608935
583213104 68480488
702991163 621318534
604391063 684474941
54372531 180001299
17375507 613800470
155120802 201292037
311762506 721264718
752936386 555513144
551436967 523141730
658723279 2...

output:

746492571845943922
808836835471628796
873103111769744668
914401520291580468
430376380329844948
547160678444141695
615386855972300356
83931890248099796
810255933119692492
146487484734308516
479432934163816580
256643306200529929
70159177663733364
748296135485726116
376127440783585292
36719098699982638...

result:

ok 247289 lines

Test #5:

score: 0
Accepted
time: 1713ms
memory: 243212kb

input:

500000 500000
774350107 70384444
230796475 124451514
983394434 36070989
38424256 575887796
323164105 28466521
177954715 333852116
333583041 6378161
521931895 44714611
443759630 102684632
947081106 954678367
140702123 704341512
180166337 803669595
198071651 823472299
778642922 590851484
818242905 362...

output:

765541310759682661
835756345246676743
956932368283560493
718421439015367741
419712568498130131
979137224693786539
6711762050089471
635886368603844166
866933941850928928
362208958202593945
663218272411092451
134874479000871010
310400810239436830
948080732862704689
503714397162410353
55898950922312158...

result:

ok 247604 lines

Test #6:

score: 0
Accepted
time: 1284ms
memory: 213244kb

input:

500000 500000
165547239 4799531
465749938 41715833
615052694 280071960
470496255 948996581
587390892 243120982
63158288 845390267
786378233 865955780
479203183 234810948
574796511 436316980
539379577 705534459
344187094 786467053
33370590 488443921
797690601 770727207
680496420 886898921
219510071 6...

output:

596330326959203672
319219444515234121
561458819690919796
304830349935095192
724926647731052847
176473632223758733
17237671590408518
134546287621521522
358143484893473368
516125825442287208
17080946204931164
649591332121983578
32631706230162023
462136205136418480
777460344745619184
402865462537911455...

result:

ok 445572 lines

Test #7:

score: 0
Accepted
time: 1535ms
memory: 269076kb

input:

500000 500000
831215807 10993499
12379772 317653535
333938577 522591788
771755048 75247276
845525371 746031565
608483151 66226978
482034366 702232902
813941818 973273282
985564879 69332528
652068008 317601185
866804949 284034365
158647884 869529897
492387373 334845614
1201482 971541143
864557286 205...

output:

41573848829347305
893985630452610985
75687161817748713
899474932509109097
555990845307893609
753027652968571177
283391663004206633
183669804142392361
127984240178744809
899659650669745961
531764972390760361
971305275110549161
895344758276706089
717157120965009257
220778534519555305
25427615630567024...

result:

ok 74483 lines

Test #8:

score: 0
Accepted
time: 1360ms
memory: 247468kb

input:

500000 500000
623773860 15290059
796976921 952297389
140052083 689823113
868426044 102090761
23858486 463423678
961380183 996362247
494260498 515307829
452340440 112585196
602421215 75407564
211404578 864620369
634846633 270785272
777223690 873120164
355871024 589602111
666983515 844810916
605966440...

output:

290644931000553111
899501734380626383
527166718201304943
65468068745224311
168230917973857055
484494962155359959
925086541643664375
418158443113803671
828375007651251943
334491307763030983
422469528733036935
495592681581351455
14301220213771223
81923062756653767
780512458696227991
782361748101202399...

result:

ok 247228 lines

Test #9:

score: 0
Accepted
time: 1043ms
memory: 207176kb

input:

500000 500000
7 19
29 44
93 75
29 28
58 13
79 45
37 58
15 66
51 19
96 2
31 37
37 30
81 3
98 45
32 65
51 86
95 50
58 88
39 58
94 45
30 39
27 23
17 76
5686 983837545
67 11
44 83
12593 920714472
4 49
11 41
72 65
14 52
31 74
82 4
6219 980665129
74 84
57 14
90 43
14551 894141475
57 72
79 25
13 26
52 24
7...

output:

37775077245550
4727795666650
24494115462250
36495273601750
26491815678250
29685182516050
6361879262650
22755855878950
22359288341050
6032800902250
20885789986750
29089768413850
24935412815050
6243415769650
29868809892550
30325634013850
24885093667450
36469531899850
207139346950
2014315155250
5574681...

result:

ok 485258 lines

Test #10:

score: 0
Accepted
time: 1274ms
memory: 204976kb

input:

500000 500000
9 92
67 74
54 38
52 6
96 76
85 13
54 19
38732 249935454
86 49
77 88
57 16
51 23
7 18
78 77
74 44
20 89
59 88
96 52
46 72
11 27
100 73
74 28
23675 719759025
46 44
61 36
25 34
6 27
30 21
84 4
28 31
32554 470134819
46 87
20 43
90 99
41 17
84 100
83 86
34030 420996565
80 49
29525 564151950...

output:

38103453145450
25084473994450
15409600585750
29661622710550
39133726325350
11155251623350
43720510841650
27439291450450
3404379216250
26519780311150
15019626655450
7065624306550
14600379052750
9530923310650
8951239406650
14381893677550
11172381959650
24535340663050
43689580810750
33871467414250
1813...

result:

ok 485194 lines

Test #11:

score: 0
Accepted
time: 1549ms
memory: 206928kb

input:

500000 500000
20049 799028824
81 57
14 97
16 12
20 46
96 30
60 9
64 9
8 71
23417 725833764
94 39
35 82
71 92
4 47
46 32
11 73
28 17
58 48
81 97
3 18
5199 986487799
83 84
9 22
49 2
86 52
7 39
2268 997429222
73 93
86 74
93 41
98 38
60 41
45 79
13 96
20020 799609810
52 49
44 9
5 37
22 6
73 78
80 79
57 ...

output:

34822089705377
12557266552298
20688874035272
16634617451050
8274825417850
7412910094450
40878611119150
43629475045150
1489922796020
9403635009550
40135146003698
37141406514250
31873754682250
147843944512
25764070667950
1933473327850
38620429833250
26057923729750
22016915932450
9952764899050
63585919...

result:

ok 485058 lines

Test #12:

score: 0
Accepted
time: 1559ms
memory: 207032kb

input:

500000 500000
54 32
77 80
45 97
43 92
15 88
73 53
52 15
30 15
9 79
85 8
83 21
47 43
41 55
17 16
100 77
73 25
39 99
37 66
12 48
5 38
11 3
1 65
14 28
76 73
30717 528248314
30 26
99 98
70 58
94 81
71 62
12 17
29 46
59 23
39 70
24 76
72 18
91 49
74 23
16 36
55 90
9 45
84 41
54 53
16 85
12 98
18 93
24 38...

output:

5740035305300
7587171551497
33153395752150
24505223079688
3661045901050
11064837925236
41858590236412
41570450415412
23849595102250
780316629550
8750826733150
21272799688216
38939541442693
32427430804163
37439890224964
15229240917667
34203655927312
13037087114950
27522011918149
34498568205730
120909...

result:

ok 485500 lines

Test #13:

score: 0
Accepted
time: 1392ms
memory: 247176kb

input:

500000 500000
7 91
55 29
33 29
56 92
76 90
86 81
82 63
48 51
82 15
18 24
58 56
15 9
22 20
30 4
7 62
25 82
45 4
98 100
61 8
42 33
94 54
25160 683499780
29 73
29 70
52 25
34 67
10 48
91 16
92 63
14 5
33 95
6423 979375747
20 24
73 93
3579 993597169
81 73
87 14
48 70
28 31
39915 203416345
81 94
40 62
10...

output:

3665982658450
38020438540450
29542090574650
17626104575050
18394019642650
776037453850
17592720737650
5365233669250
9155046508750
7391549394850
3174182753950
30324349916950
26545936382050
28753298059150
3251770957750
4722172138450
7181322210550
10098476171050
17076410616250
38007135149950
4106455690...

result:

ok 247898 lines

Test #14:

score: 0
Accepted
time: 1576ms
memory: 246504kb

input:

500000 500000
14196 899243890
51 60
40 28
75 54
7920 968640760
57 100
84 53
58 33
1 74
92 24
8888 960506172
24109 709390114
6240 980534320
55 84
34 77
16 13
6 65
87 17
24 79
25 61
39 54
19390 812023645
13 81
80 80
17 47
92 11
97 74
66 77
26 90
71 32
69 50
72 2
77 27
52 42
82 39
25 83
23 86
91 53
280...

output:

2480623990750
30531551849950
43715797718350
1746187256350
37264534094650
41318701303750
3715559204950
2460231359050
2919993521950
35305953798850
2621200931350
9847205849050
11276142058150
35902688964850
4795816416550
44302820423650
1541548376650
612407069350
18857183117950
20493671350450
22635716350...

result:

ok 247026 lines

Test #15:

score: 0
Accepted
time: 1929ms
memory: 248160kb

input:

500000 500000
88 62
18603 826973497
100 42
33 97
91 64
16 65
1 36
65 36
34 97
55 70
14 32
74 18
12 96
29 75
61 78
35 41
97 27
68 77
41 54
59 2
28 27
35239 379124059
95 5
37 94
43 63
14 88
35 37
43 2
17 93
6758 977168097
95 99
26 43
18663 825855547
26 1
79 49
52 97
38 37
53 91
7 50
67 78
69 55
46 37
...

output:

3994358513650
10379392561150
8564221442650
22708439683450
693610877350
39480427303150
27121428588250
10407777061150
8674895558350
19405205805275
2055455694250
23446979743750
38983251329650
19580613764393
36791269179250
32773555385565
7083835488850
1964657657050
32997297214097
10405285304350
24508706...

result:

ok 248734 lines

Test #16:

score: 0
Accepted
time: 1950ms
memory: 245992kb

input:

500000 500000
24 44
11 76
30 17
49 56
63 44
8606 962972685
38 96
29 84
17 72
66 26
7 81
2 56
7 62
21 54
58 2
53 37
56 38
48 54
31111 516068395
42 94
50 43
100 64
89 38
55 81
29 76
44 73
61 3
80 74
36 94
59 23
19830 803395465
43 40
19348 812837122
25 97
62 15
30610 531529255
39435 222460105
87 28
44 ...

output:

32203430189950
40741243129576
40504212590950
6182479759560
19995843516850
5513127539770
40563116416124
28478527427350
6711223043295
2183635122368
23278260487750
10367058699290
39658577812150
19978302476950
43858006373695
5212362708850
42333556654458
43642754799908
32431294340350
17284875324250
37127...

result:

ok 248160 lines

Test #17:

score: 0
Accepted
time: 1343ms
memory: 270628kb

input:

500000 500000
21 55
75 91
57 89
14 28
44 81
71 6
41 56
15 30
1 69
68 7
55 89
86 12
31137 515259184
71 25
94 10
14 40
55 24
62 10
42857 81660204
54 73
56 97
5 80
98 35
64 70
3 19
43 85
71 44
54 18
50 39
77 25
21619 766320229
41 38
35 91
44037 30393334
35506 369679735
62 28
42 6
27425 623948400
5 60
5...

output:

39419886070150
10517203331650
21473025061750
33019711998550
39551232863050
14960102168650
5482853583850
21554092847650
35868477819850
43170136593550
19293547021150
2876802996250
33977088731350
27402678395650
16979109220750
20038606129450
43903731045850
9127811513950
4699726838050
9677316928150
22862...

result:

ok 73944 lines

Test #18:

score: 0
Accepted
time: 1410ms
memory: 270728kb

input:

500000 500000
68 28
77 3
5 30
46 53
39 24
49 29
25 100
73 46
61 9
31 38
7312 973270984
16 54
79 90
76 50
3 50
85 77
57 47
5225 986352300
93 19
3 19
57 81
24 51
64 69
63 22
37057 313407904
99 62
39 90
68 99
32 25
40 22
45 60
14 51
35 90
24 89
74 23
57 63
39 66
82 48
45 4
51 55
87 40
58 60
85 100
45 8...

output:

18435762831572
13542843787797
21275652558942
10158496728753
35319558777766
24519570289452
27225104656602
13742315042053
32335293470647
2053368978078
17558403350140
29583675998962
27491286665214
2005929571786
17651838250927
30735317350097
35620325743648
3557089467446
22849905701263
12458221435322
252...

result:

ok 73764 lines

Test #19:

score: 0
Accepted
time: 1560ms
memory: 270468kb

input:

500000 500000
6285 980252530
5 98
22 50
89 61
100 80
30875 523382625
10 74
38 52
13 85
6 20
54 93
18347 831702969
2 53
18 52
52 49
41 50
33 30
79 5
50 4
77 17
19327 813243199
89 17
99 30
57 97
22 95
87 38
4 94
83 25
10 67
6463 979118047
57 71
31532 502882254
37 1
22895 737920935
21689 764804484
46 7...

output:

25643152424424
15690887154965
14510903217002
31041055738759
29837824634483
26977167885810
28519263003066
20081582738211
29692638974757
34282530177230
23228473064605
35136506583685
555762730823
18606320373289
42940243102244
10140747649833
12847538150650
15867949379350
34253533041950
37689429312142
31...

result:

ok 74156 lines

Test #20:

score: 0
Accepted
time: 1567ms
memory: 268392kb

input:

500000 500000
28 48
7 43
23216 730520280
44 17
99 64
70 13
85 49
58 72
29 92
18 51
91 100
39 41
76 5
11 76
17 71
35342 375489189
82 6
2 16
100 52
25670 670538385
7 93
51 4
3 2
99 95
15 72
23165 731702970
82 85
34 47
2 88
76 36
38 1
84 42
42143 112004847
22 69
79 43
93 71
65 76
97 52
86 95
81 39
51 1...

output:

20486948291650
32172745249150
7298172927550
1851296311450
7766980358950
2311564165450
1666288062550
37005027663550
20988675100463
571865187981
17581049164626
20041046525950
39300208644604
9138765919450
2953772999050
29757830967550
6229039837215
14239953659700
8654562189068
22015915278250
18309816365...

result:

ok 73934 lines

Test #21:

score: 0
Accepted
time: 996ms
memory: 204480kb

input:

500000 500000
49194290 730540991
7443981 774397204
580675305 86867295
153326073 556280353
13011637 852738248
84055423 58924081
830905991 246139754
741379564 915383740
220538660 235233257
789182365 291866290
828283044 143721116
385501319 740231412
178298614 128130577
868245679 857312473
625653339 493...

output:

369394068060647360
103814051889043954
487051026821953702
53760097007502378
154128734681416554
210227206495732632
622525205489768752
442103212194111562
545776523737826888
502877645409248294
945082414175165654
701734250400266128
511756996372509226
427324413248462530
573156050374025576
9661132079826317...

result:

ok 490211 lines

Test #22:

score: 0
Accepted
time: 1002ms
memory: 203172kb

input:

500000 500000
15875356 733888847
947879316 514570389
430435391 753308897
147735938 496565706
798960486 177403894
303851244 917466838
1482657 47580816
568561011 328878653
51035331 427821653
71875771 232652647
755891170 375031054
140097261 555155744
126175705 728255272
743469878 87992343
452065222 528...

output:

753800537695723136
133352576406127171
924237138746090481
360008595015680381
550652315576516456
37892875751833191
611155179216345571
868601644652614156
785641179561509171
663934872922881641
732897986821574686
953605008874464726
67659021515784896
392947322876716811
647293823149456116
18031705943358588...

result:

ok 485224 lines

Test #23:

score: 0
Accepted
time: 1138ms
memory: 208208kb

input:

500000 500000
908847367 737203936
888281882 254776342
280195476 346074211
142145803 436818290
511134743 575745828
523647064 702267771
98284731 922763703
395709690 816148158
807790178 620442817
428278233 173406237
683466527 606340991
968467796 370080076
74085563 254638144
618628541 392414037
27847710...

output:

64433429818762731
162825172063146849
287681886466167177
947173349317215180
791781023804766480
599718304863263493
221358873663252003
25506991730336385
382786808861969199
321711577657933728
781699772075291913
212738331533514081
39084380534544402
506008798308590034
699073349546305329
203579654393268648...

result:

ok 470568 lines

Test #24:

score: 0
Accepted
time: 1416ms
memory: 268916kb

input:

500000 500000
316776185 739428500
882551545 910087731
178418993 970732558
380798798 638787267
697161177 776345238
118355907 41413991
802683969 234048737
313283290 176387829
123468221 543126150
358016601 514284134
669080616 35681410
836871627 452484953
592962652 522597299
845867264 460123791
43799673...

output:

22168517606974841
405905406648587794
363518615501676968
74623767297373
691588643822543008
827357833559753411
52002372444917106
528510329694885277
319812802688298395
586358691210132657
392473387228373157
653860767965464062
804180184992379803
449219511857983155
62464505867689522
508047885382437392
422...

result:

ok 74191 lines

Test #25:

score: 0
Accepted
time: 1324ms
memory: 268384kb

input:

500000 500000
403765473 743179798
157194947 928509710
8780599 580217727
62736832 259650804
649291292 394882473
158676682 174980079
544950474 875771090
533765284 899701242
56640683 414199503
240892035 724478177
2930657 158302086
975480466 589881029
741962687 611336562
150736495 214972059
345926989 51...

output:

646499944488453850
940673593704322090
358002533768963122
772510921513249090
621983069728724974
808271323640085190
77471384677303390
788811247505136538
776110787144068282
175288433576768530
71853717979672486
867479845198906090
223367193377582230
395490663959305198
332262970210407394
39659261417299125...

result:

ok 24758 lines

Test #26:

score: 0
Accepted
time: 1245ms
memory: 267172kb

input:

500000 500000
684739270 747367306
913530063 151405893
893485548 206389985
505977625 634768815
841377266 307258529
19555179 804794972
932681409 210323855
73871537 785349507
166263527 37565172
723949497 130403616
669411861 172167965
424327608 49748847
18311073 188657626
32865478 494054261
335375621 19...

output:

280113519808838541
771017901728542961
11029781895495981
405647979372449861
560830877608324661
195132164442458601
894032634413598601
524643181608258401
331299519514848841
767549394284585361
578198671736682321
310480781878951901
628881288264946321
47603948496533601
224017150878429181
27442177482408881...

result:

ok 10033 lines

Test #27:

score: 0
Accepted
time: 1194ms
memory: 268148kb

input:

500000 500000
674687151 750900500
57940343 567590771
733546394 881207898
881022486 952181403
673529452 315698113
149646245 264011251
352248467 968809243
97703257 853720903
11194414 69412431
306717533 205893816
800140944 349116888
370962767 25892667
66749636 69911366
622912193 60592922
739384836 5960...

output:

11437257809757530
872146266900671786
763335413470192822
126028924698821570
840178950680311110
391257940978824122
45485726354760830
367778541826990554
488577821959959474
269768256046023322
928680314083021150
992473475589309606
205921268945152298
45374639191475646
48794482433022338
131767871472748890
...

result:

ok 4947 lines

Test #28:

score: 0
Accepted
time: 974ms
memory: 206532kb

input:

500000 500000
7445 972289710
42 28
89 19
86 46
10 22
48 90
13 55
67 94
28 14
5 36
12 60
97 16
36 98
7722 970189219
48 60
53 41
8 93
68 84
93 65
99 22
83 17
76 49
40 91
31 81
25 56
41 18
65 63
4 30
1 62
14 64
14422 896010169
55 21
5 21
35 2
69 25
86 46
6000 982003000
75 76
91 60
49 85
96 37
53 14
84 ...

output:

2830346529541
42049008425426
40198839311050
42714968294350
13960809028535
17844676087150
13702259597668
5642037490470
32526897477408
28069934172590
36202303684116
33194554282280
1545681267299
80380641207
7413587191299
44181367023887
16692651394426
14925453409441
31531141966716
9723268242526
26825040...

result:

ok 490096 lines

Test #29:

score: 0
Accepted
time: 1164ms
memory: 206624kb

input:

500000 500000
35 83
37 98
25 7
21 92
63 52
33424 441434824
93 27
99 27
24 56
15 95
9 22
50 85
11 68
26 32
63 32
34 67
31 3
57 65
67 41
36 42
74 40
17 51
82 7
16613 862012422
2 5
4 92
38 4
80 52
71 66
22 59
61 17
33 63
73 89
17873 840286872
54 39
51 85
92 62
52 91
99 77
14 40
15 4
5 64
87 56
62 61
36...

output:

4345609057450
21897789851350
5047263035350
18975756036550
39966650033350
14124690503350
35306744720650
6299562635050
1503402067150
30212778627550
26888071344250
11724499686550
9433526793550
32969711919550
5103786721750
7523934211150
15718272189250
41344583810650
24928349008150
14279920461550
4124576...

result:

ok 490202 lines

Test #30:

score: 0
Accepted
time: 942ms
memory: 205056kb

input:

500000 500000
65 5
51 38
1 89
80 4
93 2
69 11
53 43
6 64
19 51
57 58
24 5
76 75
41 89
83 93
31 72
94 100
54 43
84 59
66 70
63 74
37 82
60 18
74 88
43470 55201285
35 59
11 11
60 15
43 58
69 98
6 32
5 13
3 57
41 83
28 55
5230 986326165
40 7
85 88
9501 954870250
35 51
44 68
90 20
59 46
60 32
69 69
92 4...

output:

33755714529250
2525799643450
31494948734050
4268390165050
9227545438750
39938101216150
23611687711150
13038302686750
1591129661350
14624541146050
4412330333650
5566070054050
40015302005050
3975533868550
20503305764950
26277619312750
20620658597050
29066805755650
35499658566850
31405523746750
3947200...

result:

ok 485098 lines

Test #31:

score: 0
Accepted
time: 962ms
memory: 251364kb

input:

500000 500000
8993 959567472
16187 868998609
12736 918903520
20942 780726789
30010 549714955
10009 949914964
33397 442336894
24064 710473984
21818 761998347
41787 126944209
31205 513139590
20174 796514949
39247 229856119
43794 41064679
4 55
29568 562881472
38994 239753479
24194 707337279
21589 76696...

output:

1039149923350
13601500783750
25438396659550
29101044704050
38861433056950
20660851540750
29977944361450
35476623539350
6518375705950
8792099137150
39773506473850
35268182120050
17862001360150
8058408624550
11464024651150
10675932405850
40451487108250
10635884200750
32316640807150
14432546555350
2919...

result:

ok 489950 lines

Test #32:

score: 0
Accepted
time: 1077ms
memory: 251492kb

input:

500000 500000
37640 291634020
1677 998594674
26886 638584945
12986 915688395
36728 325545372
31388 507412422
35283 377572597
23161 731795620
25039 686536759
28484 594345114
18254 833404869
8997 959531494
22251 752457625
29846 554623065
20117 797663214
17488 847093672
13459 909434389
33593 435771972
...

output:

4599856935850
27434322062050
35801923408750
25729773386050
17151866808850
38330595033250
8160418449850
8127004708150
8661506656750
39643251389050
1082999774050
10024199119750
1589442191650
9544688094550
23128174963150
34331990371150
19862118728650
2841541803550
24744465321850
36100147996450
55738499...

result:

ok 485240 lines

Test #33:

score: 0
Accepted
time: 1172ms
memory: 252800kb

input:

500000 500000
12803 918047997
7858 969129847
28095 605349535
37870 282950485
9704 952921044
8104 967166644
9813 951857422
33875 426259125
5063 987185547
39896 204174540
40691 172141605
24415 701966095
4821 988381390
8865 960710320
40581 176611510
31642 499407739
30146 545624415
39835 206606305
18051...

output:

30180552609550
1105466575150
41433817928950
43881377335750
43370315664850
37403342703250
2033203542550
14748640638550
18676426375450
34302402189550
13826352109450
5414559672250
28547823423550
42860049341050
9746637956350
1610181114250
15613758180550
24970344881650
13851229223950
30103686042550
38002...

result:

ok 470028 lines

Test #34:

score: 0
Accepted
time: 1563ms
memory: 268968kb

input:

500000 500000
809 999673164
3316 994503730
17859 840536989
22728 741730372
4982 987592329
20988 779762422
29526 564122425
10879 940829119
43638 47884297
6795 976917385
7883 968933097
24229 706489894
35192 380779164
38625 254074000
23310 728333605
22045 757020010
24085 709968430
37998 278094997
26553...

output:

3147946670050
10633648932550
13041352433650
25373124289150
8494166351050
24040706778550
12355494541750
12396118080550
6372680034250
37662757186450
44173577883250
39668542112650
16879961178850
3133629349450
6225423840850
24860869441150
24152563566850
6137321660650
39232352092450
23602448265850
624049...

result:

ok 248348 lines

Test #35:

score: 0
Accepted
time: 1483ms
memory: 284868kb

input:

500000 500000
12775 918406075
31019 518926329
42 999999139
809 999673164
11524 933604474
87 16
5838 982961797
31035 518429905
10025 949754700
30409 537661564
17230 851572165
5654 984018969
27386 625017195
27994 608181979
31609 500451364
35604 366195394
15749 875992374
30465 535957120
2683 996402097
...

output:

3543521823250
29124992192650
16306920588850
22025524124350
9524732226550
37492503602950
23003620156450
38870413733950
44673516540250
4359604940350
13867183905550
11041836995350
11790752551450
41275520969650
11571653892250
8707524680950
3667033823650
32306860000150
25407357337150
9392872769350
408935...

result:

ok 25078 lines

Test #36:

score: 0
Accepted
time: 1441ms
memory: 285268kb

input:

500000 500000
31016 519019380
43330 61277215
6722 977410719
10074 949262299
37342 302806189
19557 808771654
43311 62100295
40136 194570820
4888 988056172
29976 550734700
36274 342116599
27361 625701520
27800 613593900
39540 218313970
69 58
38018 277334847
5645 984069810
18857 822216204
1895 99820543...

output:

15289857063550
38371138067350
40233455482750
9882951098050
9457838944750
21243331697950
16720735040650
6207458150950
12464502464950
20331399980050
9977044240450
14337544706650
28640473694650
38600372630350
32753034301750
31403350164550
30545115886150
34947233303950
19279482479050
8076874015750
37432...

result:

ok 9866 lines

Extra Test:

score: 0
Extra Test Passed