QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#412917#8672. 排队g1ove30 532ms72316kbC++142.0kb2024-05-16 21:37:042024-05-16 21:37:04

Judging History

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

  • [2024-05-16 21:37:04]
  • 评测
  • 测评结果:30
  • 用时:532ms
  • 内存:72316kb
  • [2024-05-16 21:37:04]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
#define N 1000005
using namespace std;
const int inf=1e9;
int n,m;
int l[N],r[N];
int stk[N],top;
struct segtree{
	int tr[N*4],lz[N*4],p[N*4];
	void Pushup(int x)
	{
		if(tr[x*2]<=tr[x*2+1]) tr[x]=tr[x*2],p[x]=p[x*2];
		else tr[x]=tr[x*2+1],p[x]=p[x*2+1];
	} 
	void Pushdown(int x)
	{
		if(!lz[x]) return;
		tr[x*2]+=lz[x];
		tr[x*2+1]+=lz[x];
		lz[x*2]+=lz[x];
		lz[x*2+1]+=lz[x];
		lz[x]=0;
	}
	void modify(int l,int r,int L,int R,int x,int v)
	{
		if(l>R||r<L) return;
		if(l>=L&&r<=R)
		{
			tr[x]+=v;
			lz[x]+=v;
			if(l==r) p[x]=l;
			return;
		}
		int mid=(l+r)/2;
		Pushdown(x);
		modify(l,mid,L,R,x*2,v);
		modify(mid+1,r,L,R,x*2+1,v);
		Pushup(x);
	}
	int query(int l,int r,int p,int x)
	{
		if(l==r) return tr[x];
		int mid=(l+r)/2;
		Pushdown(x);
		if(p<=mid) return query(l,mid,p,x*2);
		else return query(mid+1,r,p,x*2+1);
	}
}tr1,tr2,tr3;
int ans[N];
struct node{
	int p,id;
};
vector<node> E[N];
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
		scanf("%d%d",&l[i],&r[i]);
	tr1.modify(1,n,1,n,1,inf);
	tr2.modify(1,n,1,n,1,inf);
	for(int i=1;i<=m;i++)
	{
		int l,r;
		scanf("%d%d",&l,&r);
		E[l].push_back((node){r,i});
	}
	for(int i=n;i>=1;i--)
	{
		tr1.modify(1,n,i,i,1,l[i]-inf);
		tr2.modify(1,n,i,i,1,r[i]+1-inf);
		while(1)
		{
			int l1=tr1.p[1],l2=tr2.p[1];
			if(tr1.tr[1]>0&&tr2.tr[1]>0) break;
			if(tr1.tr[1]>0) l1=inf;
			if(tr2.tr[1]>0) l2=inf;
			if(l1<l2)
			{
				tr1.modify(1,n,l1,l1,1,inf);
				tr1.modify(1,n,l1+1,n,1,-1);
				tr2.modify(1,n,l1+1,n,1,-1);
				tr3.modify(1,n,l1,n,1,1);
			}
			else
			{
				tr2.modify(1,n,l2,l2,1,inf);
				tr1.modify(1,n,l2+1,n,1,1);
				tr2.modify(1,n,l2+1,n,1,1);
				tr3.modify(1,n,l2,n,1,-1);
			}
		}
//		for(int j=i;j<=n;j++) printf("%d ",tr3.query(1,n,j,1));
//		printf("\n");
		for(auto u:E[i]) ans[u.id]=tr3.query(1,n,u.p,1);
	}
	for(int i=1;i<=m;i++) printf("%d\n",ans[i]);
	return 0;
}

詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 10
Accepted
time: 3ms
memory: 43852kb

input:

3 3
0 0
1 2
0 2
1 1
1 3
2 3

output:

1
3
1

result:

ok 3 number(s): "1 3 1"

Test #2:

score: -10
Wrong Answer
time: 8ms
memory: 45848kb

input:

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

output:

11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
...

result:

wrong answer 3023rd numbers differ - expected: '8', found: '9'

Subtask #2:

score: 0
Wrong Answer

Test #12:

score: 15
Accepted
time: 358ms
memory: 68552kb

input:

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

output:

11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
...

result:

ok 200000 numbers

Test #13:

score: -15
Wrong Answer
time: 382ms
memory: 64532kb

input:

200000 200000
5 45
27 99
7 23
51 88
16 62
10 24
16 80
43 70
12 45
35 55
6 99
77 91
40 82
66 99
30 47
18 80
9 36
4 12
26 51
37 64
39 52
2 11
2 69
57 81
15 98
8 36
19 27
32 34
35 97
22 23
15 89
53 77
2 89
25 55
25 90
4 91
13 77
37 65
67 89
8 52
20 58
10 18
31 81
35 59
41 56
71 74
18 61
56 77
51 74
40 ...

output:

101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
0
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
10...

result:

wrong answer 495th numbers differ - expected: '56', found: '59'

Subtask #3:

score: 15
Accepted

Test #22:

score: 15
Accepted
time: 341ms
memory: 68264kb

input:

200000 200000
0 1
0 2
0 3
0 4
0 5
0 6
0 7
0 0
0 9
0 10
0 0
0 0
0 13
0 14
0 0
0 16
0 17
0 18
0 19
0 0
0 21
0 22
0 23
0 0
0 0
0 0
0 0
0 28
0 0
0 30
0 31
0 32
0 33
0 34
0 35
0 0
0 0
0 38
0 39
0 40
0 41
0 42
0 43
0 44
0 45
0 46
0 0
0 48
0 49
0 50
0 51
0 52
0 53
0 54
0 55
0 56
0 57
0 0
0 59
0 60
0 0
0 0
...

output:

19141
39288
14841
58655
15427
4999
26338
93250
2826
78084
64070
55481
2565
15173
24866
57627
35887
51335
67552
44939
27730
24781
54502
26903
73199
7553
3836
41740
67889
104576
43522
3766
13007
31659
17264
85349
16595
28681
64012
56457
23856
47820
22752
86123
37679
44828
88810
36305
15843
33728
10005...

result:

ok 200000 numbers

Test #23:

score: 0
Accepted
time: 336ms
memory: 70252kb

input:

200000 200000
0 1
0 2
0 3
0 4
0 5
0 6
0 7
0 8
0 9
0 10
0 11
0 0
0 13
0 14
0 15
0 16
0 17
0 18
0 19
0 20
0 21
0 22
0 23
0 24
0 25
0 0
0 27
0 28
0 29
0 30
0 0
0 32
0 33
0 34
0 35
0 36
0 0
0 0
0 39
0 40
0 41
0 42
0 43
0 44
0 45
0 46
0 47
0 48
0 49
0 50
0 51
0 52
0 53
0 54
0 55
0 56
0 0
0 58
0 59
0 60
0...

output:

168949
95410
33682
47935
82249
25613
65578
22342
60917
30684
99457
21252
87719
9508
41909
17405
96346
6219
110867
56725
71026
2090
45186
37640
26229
36720
91410
64919
7095
29903
44679
40307
100104
41603
87434
53924
53758
80720
59404
164539
38810
117092
13565
110110
38606
32273
93240
81294
10356
1504...

result:

ok 200000 numbers

Test #24:

score: 0
Accepted
time: 322ms
memory: 70128kb

input:

200000 200000
0 1
0 2
0 3
0 4
0 5
0 6
0 7
0 8
0 9
0 10
0 11
0 12
0 13
0 14
0 15
0 16
0 17
0 18
0 19
0 20
0 21
0 22
0 23
0 24
0 25
0 26
0 27
0 28
0 29
0 30
0 31
0 32
0 33
0 34
0 35
0 36
0 37
0 38
0 39
0 40
0 41
0 42
0 43
0 44
0 45
0 46
0 47
0 48
0 49
0 50
0 51
0 52
0 53
0 54
0 55
0 56
0 57
0 58
0 59
...

output:

69217
146306
97579
32894
129999
10418
98425
25273
33368
29464
14306
2073
112582
140228
24801
40781
52137
17338
110491
48418
54730
20451
84100
80588
2089
108163
29975
56448
14978
35560
102453
18613
30516
18699
83182
28795
25862
126187
116576
99593
36207
13935
27150
75205
66741
91089
151786
19917
2529...

result:

ok 200000 numbers

Test #25:

score: 0
Accepted
time: 442ms
memory: 69632kb

input:

200000 200000
0 5
0 99
0 23
0 88
0 62
0 24
0 80
0 70
0 45
0 55
0 99
0 91
0 82
0 99
0 47
0 80
0 9
0 4
0 51
0 64
0 52
0 2
0 2
0 81
0 98
0 36
0 27
0 34
0 97
0 22
0 89
0 77
0 89
0 25
0 90
0 91
0 77
0 37
0 89
0 52
0 58
0 18
0 81
0 35
0 56
0 71
0 18
0 56
0 74
0 40
0 76
0 47
0 87
0 11
0 81
0 48
0 59
0 17
0...

output:

101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
...

result:

ok 200000 numbers

Test #26:

score: 0
Accepted
time: 479ms
memory: 69752kb

input:

200000 200000
0 193
0 229
0 553
0 197
0 718
0 370
0 853
0 695
0 764
0 571
0 714
0 700
0 692
0 293
0 962
0 536
0 482
0 148
0 804
0 864
0 925
0 864
0 296
0 757
0 283
0 338
0 746
0 447
0 365
0 390
0 689
0 239
0 60
0 388
0 822
0 836
0 373
0 703
0 107
0 894
0 468
0 125
0 851
0 568
0 914
0 391
0 759
0 66
...

output:

1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
986
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
834
1001
999
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
995
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001...

result:

ok 200000 numbers

Test #27:

score: 0
Accepted
time: 515ms
memory: 68308kb

input:

200000 200000
0 7698
0 6154
0 6707
0 7442
0 9621
0 8045
0 8938
0 5518
0 4134
0 3188
0 8054
0 5380
0 2409
0 3360
0 2771
0 9642
0 8264
0 4305
0 2844
0 7810
0 4706
0 1462
0 6282
0 2481
0 2987
0 3633
0 2634
0 4866
0 5079
0 2325
0 4394
0 8361
0 322
0 2614
0 7668
0 9067
0 452
0 2834
0 3340
0 2193
0 4070
0...

output:

9992
10001
10001
10000
10001
10001
9910
9932
2155
6995
10001
9347
10001
10001
10000
8952
9997
10000
9996
9999
10001
9996
10001
10000
9949
8842
9944
10000
10000
6517
9719
7997
10001
9875
10000
10001
10001
10001
10001
7481
10001
564
9962
8180
10001
7708
9902
9995
6677
10000
10000
9993
9841
6942
9584
1...

result:

ok 200000 numbers

Test #28:

score: 0
Accepted
time: 532ms
memory: 70064kb

input:

200000 200000
0 44932
0 12196
0 776
0 35673
0 44618
0 16521
0 9747
0 42216
0 21955
0 3389
0 22
0 15248
0 5734
0 45217
0 47977
0 8869
0 25942
0 3415
0 40771
0 28517
0 29726
0 13420
0 30474
0 44930
0 10541
0 4648
0 26903
0 19507
0 2998
0 24757
0 10645
0 47790
0 25779
0 41892
0 37322
0 34913
0 36562
0 ...

output:

48090
32992
22437
48207
21332
45359
39653
11005
43989
17371
8176
34898
30342
43305
36171
34310
36953
26580
26406
40517
30042
24009
21601
48636
34590
44645
6569
1680
36941
44685
8184
29538
47471
13134
37634
44021
16542
45480
34004
2798
44629
42393
43534
32749
42758
39005
46942
906
35042
32188
39406
4...

result:

ok 200000 numbers

Test #29:

score: 0
Accepted
time: 492ms
memory: 69252kb

input:

200000 200000
0 17611
0 59430
0 23731
0 61357
0 32905
0 30945
0 53122
0 18775
0 25563
0 43076
0 23316
0 71711
0 16622
0 27384
0 9838
0 81042
0 85530
0 32497
0 12816
0 55180
0 2256
0 81719
0 61844
0 64533
0 5302
0 33711
0 18419
0 98385
0 48813
0 58297
0 63392
0 29066
0 12542
0 14198
0 27695
0 23110
0...

output:

20413
33643
27062
9573
23562
70288
46728
62984
61505
69707
52256
43819
42924
84768
46751
32254
29961
25002
61760
47063
54538
23381
4229
40146
56797
35682
73141
55198
81237
4145
14779
79432
46593
8554
55961
48948
59145
73439
77423
43568
51349
68840
23328
1413
10825
33789
61183
12488
53414
60374
77583...

result:

ok 200000 numbers

Test #30:

score: 0
Accepted
time: 442ms
memory: 72316kb

input:

200000 200000
0 19
0 50
0 16
0 8
0 27
0 35
0 43
0 42
0 8
0 45
0 39
0 16
0 23
0 29
0 10
0 10
0 50
0 23
0 50
0 45
0 16
0 17
0 30
0 17
0 35
0 50
0 2
0 15
0 33
0 41
0 38
0 12
0 2
0 5
0 37
0 11
0 26
0 35
0 25
0 12
0 38
0 28
0 5
0 46
0 46
0 39
0 26
0 36
0 22
0 9
0 1
0 45
0 36
0 6
0 15
0 31
0 2
0 3
0 0
0 4...

output:

51
51
51
51
51
51
51
51
51
27
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
...

result:

ok 200000 numbers

Test #31:

score: 0
Accepted
time: 427ms
memory: 69780kb

input:

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

output:

11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
...

result:

ok 200000 numbers

Subtask #4:

score: 15
Accepted

Test #32:

score: 15
Accepted
time: 332ms
memory: 69692kb

input:

200000 200000
0 200000
1 200000
1 200000
0 200000
0 200000
1 200000
1 200000
1 200000
0 200000
1 200000
0 200000
0 200000
1 200000
0 200000
0 200000
0 200000
0 200000
1 200000
0 200000
0 200000
1 200000
0 200000
1 200000
1 200000
1 200000
1 200000
0 200000
0 200000
1 200000
2 200000
1 200000
2 20000...

output:

71224
21392
65746
47218
62293
29293
146310
136621
165312
81582
25124
120262
104926
12518
90915
31784
50073
15588
1517
106447
92329
71506
16694
4846
38213
34902
133281
98867
697
26263
6631
173459
61316
71682
15564
112191
125788
15305
41840
30379
24107
17435
10898
115177
22279
37582
101778
120170
1264...

result:

ok 200000 numbers

Test #33:

score: 0
Accepted
time: 317ms
memory: 69640kb

input:

200000 200000
5 200000
0 200000
1 200000
0 200000
2 200000
1 200000
0 200000
3 200000
4 200000
1 200000
0 200000
2 200000
1 200000
0 200000
0 200000
5 200000
2 200000
0 200000
2 200000
2 200000
0 200000
1 200000
3 200000
4 200000
2 200000
0 200000
5 200000
0 200000
3 200000
0 200000
0 200000
5 20000...

output:

51850
27495
33433
90638
103054
58851
115355
44294
80395
72594
155250
20604
154366
112939
168447
70437
134688
175930
112777
43168
73760
136485
95405
115772
19580
14448
85020
8135
266
66591
24765
14783
101583
182811
27593
75020
64180
50889
69744
140901
99500
62001
74634
142631
93413
188391
25666
29627...

result:

ok 200000 numbers

Test #34:

score: 0
Accepted
time: 330ms
memory: 68688kb

input:

200000 200000
6 200000
3 200000
6 200000
7 200000
2 200000
9 200000
4 200000
3 200000
0 200000
6 200000
3 200000
3 200000
1 200000
8 200000
4 200000
3 200000
5 200000
2 200000
2 200000
2 200000
4 200000
5 200000
6 200000
3 200000
7 200000
1 200000
2 200000
7 200000
2 200000
1 200000
6 200000
1 20000...

output:

48539
120803
28813
145711
29729
172683
112151
52277
31739
73432
63297
64022
176699
103343
145926
110637
5216
25387
86738
39373
77641
3608
134147
26930
117814
50832
9240
59137
73006
34370
34497
804
96016
101388
3489
30001
85307
17852
1324
32486
37351
12503
28321
42856
196324
95124
119392
87948
28069
...

result:

ok 200000 numbers

Test #35:

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

input:

200000 200000
45 200000
27 200000
7 200000
51 200000
16 200000
10 200000
16 200000
43 200000
12 200000
35 200000
6 200000
77 200000
40 200000
66 200000
30 200000
18 200000
36 200000
12 200000
26 200000
37 200000
39 200000
11 200000
69 200000
57 200000
15 200000
8 200000
19 200000
32 200000
35 200000...

output:

102146
138864
3922
35890
61622
45382
45112
14900
58606
39462
173762
102549
8848
81805
48479
48103
10353
63948
139153
34744
24441
35639
58427
40153
41974
28423
106874
11420
118809
141816
59608
59417
25106
134727
11556
40866
27752
61000
52123
94606
325
144695
24421
115649
156435
132658
25786
136006
18...

result:

ok 200000 numbers

Test #36:

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

input:

200000 200000
894 200000
142 200000
346 200000
496 200000
389 200000
600 200000
650 200000
476 200000
767 200000
220 200000
238 200000
516 200000
137 200000
1 200000
835 200000
34 200000
208 200000
225 200000
377 200000
75 200000
277 200000
278 200000
647 200000
390 200000
179 200000
602 200000
571 ...

output:

82980
71975
66684
28250
111297
44819
114569
54121
107328
25452
72738
53632
23692
426
71363
73241
154868
34365
20278
17775
146745
22972
136874
69984
53
79587
2967
124150
52120
87623
89603
4325
87876
13984
119053
27551
69825
112363
84048
157846
1462
94224
79643
115628
117698
116223
38012
32665
94002
1...

result:

ok 200000 numbers

Test #37:

score: 0
Accepted
time: 258ms
memory: 67396kb

input:

200000 200000
30 200000
9 200000
18 200000
24 200000
68 200000
54 200000
26 200000
3 200000
42 200000
32 200000
27 200000
58 200000
1 200000
34 200000
16 200000
61 200000
11 200000
25 200000
69 200000
48 200000
1 200000
11 200000
51 200000
46 200000
45 200000
48 200000
8 200000
11 200000
76 200000
1...

output:

173724
167565
196183
155627
73842
112798
182774
198559
148707
78823
124508
189149
139326
167284
179483
145557
81468
183248
195819
198503
179022
158694
167743
30007
115871
163056
159742
39661
110436
112768
148610
172927
108963
141742
144742
195300
136697
158981
169064
113954
164065
191476
87872
11760...

result:

ok 200000 numbers

Test #38:

score: 0
Accepted
time: 232ms
memory: 65756kb

input:

200000 200000
4 200000
3 200000
5 200000
9 200000
3 200000
5 200000
3 200000
4 200000
1 200000
7 200000
5 200000
2 200000
2 200000
5 200000
7 200000
0 200000
2 200000
1 200000
6 200000
7 200000
3 200000
4 200000
5 200000
2 200000
2 200000
6 200000
2 200000
8 200000
8 200000
2 200000
2 200000
0 20000...

output:

46615
181434
182190
170634
93896
160383
177806
162444
168792
138030
132992
146565
174737
175152
50188
136539
105800
168041
179972
82742
181959
171407
173501
132587
137393
55914
157218
61659
132609
192152
167976
117558
60445
119612
112065
109544
154984
108960
161879
140516
153475
78686
127811
108796
...

result:

ok 200000 numbers

Test #39:

score: 0
Accepted
time: 267ms
memory: 63472kb

input:

200000 200000
200 200000
418 200000
690 200000
193 200000
63 200000
799 200000
474 200000
40 200000
287 200000
38 200000
204 200000
334 200000
258 200000
262 200000
269 200000
368 200000
167 200000
30 200000
51 200000
55 200000
119 200000
523 200000
33 200000
896 200000
253 200000
674 200000
119 200...

output:

171189
85389
126329
140440
183837
83618
89897
140242
183271
155531
156556
101126
70897
129804
140582
38794
150678
129225
97071
167132
123699
102800
162069
161274
162407
179233
150750
147270
150942
171716
178973
170764
152580
176935
138712
165104
157524
7651
105384
116173
174996
159737
138067
119161
...

result:

ok 200000 numbers

Test #40:

score: 0
Accepted
time: 288ms
memory: 62032kb

input:

200000 200000
611 200000
1167 200000
3159 200000
3415 200000
2254 200000
697 200000
6942 200000
23 200000
1856 200000
894 200000
6650 200000
3813 200000
5825 200000
5844 200000
5534 200000
6993 200000
3021 200000
515 200000
1584 200000
2031 200000
265 200000
8912 200000
6889 200000
6934 200000
833 2...

output:

73994
144591
49265
71224
136162
94664
159060
157355
118335
31810
103232
94713
103259
155339
60542
143894
121148
83887
112143
121172
58706
128573
148964
30102
37612
48511
115410
139260
109
43908
122649
126684
199
98137
22165
80600
2
77835
100163
132242
113078
105702
88160
62364
9
91895
58316
158056
1...

result:

ok 200000 numbers

Test #41:

score: 0
Accepted
time: 137ms
memory: 65728kb

input:

200000 200000
3480 200000
36579 200000
10485 200000
18356 200000
20788 200000
3352 200000
4565 200000
33362 200000
6894 200000
25647 200000
5915 200000
19265 200000
3530 200000
26535 200000
18506 200000
18191 200000
35793 200000
7442 200000
993 200000
14550 200000
13606 200000
5553 200000
12284 2000...

output:

5275
1880
872
857
82
152
7419
496
461
371
2714
1207
660
1744
219
63
17
3346
5677
461
1231
196
2250
97
3770
214
986
189
180
584
2666
0
821
107
839
8
223
90
476
71
867
107
6918
4760
4033
454
3138
1159
6072
4693
56
191
186
245
474
104
377
3627
141
3367
3835
1005
2433
223
6480
2854
29
213
120
6433
57
11...

result:

ok 200000 numbers

Subtask #5:

score: 0
Skipped

Dependency #1:

0%

Subtask #6:

score: 0
Skipped

Dependency #5:

0%