QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#311393#3290. Starting a Scenic Railroad ServiceNYCU_CartesianTree#AC ✓130ms28580kbC++142.0kb2024-01-22 12:01:132024-01-22 12:01:13

Judging History

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

  • [2024-01-22 12:01:13]
  • 评测
  • 测评结果:AC
  • 用时:130ms
  • 内存:28580kb
  • [2024-01-22 12:01:13]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int const N = 2e5 + 5, V = 1e5 + 5;
struct Line{
    int l, r;
    int id;
}line[N];
int n;
int bitr[N], bitl[N];
int lowbit(int x){
    return x & (-x);
}
int query(int x, int *bit){
    int sum = 0;
    while(x > 0){
        sum += bit[x];
        x -= lowbit(x);
    }
    return sum;
}
void modify(int x, int val, int *bit){
    while(x <= V){
        bit[x] += val;
        x += lowbit(x);
    }
}
vector<int> rId[N], lId[N];
int num[N];
int solve1(){
    for(int i = 1; i <= n; i++){
        rId[line[i].r].push_back(i);
        lId[line[i].l].push_back(i);
    }
    for(int i = 1; i <= V; i++){
        for(auto j : rId[i]){
            modify(line[j].r, 1, bitr);
            modify(line[j].l, 1, bitl);
        }
        for(auto j : rId[i]){
            num[line[j].id] += query(line[j].r, bitr) - query(line[j].l, bitr) - (query(line[j].r - 1, bitl) - query(line[j].l - 1, bitl));
        }
    }
    for(int i = 1; i <= V; i++){
        bitl[i] = 0;
    }
    for(int i = V; i >= 1; i--){
        for(auto j : lId[i]){
            modify(line[j].l, 1, bitl);
        }
        for(auto j :  lId[i]){
            num[line[j].id] += query(line[j].r - 1, bitl) - query(line[j].l - 1, bitl);
        }
    }
    int ans = 0;
    for(int i = 1; i <= n; i++){
        ans = max(ans, num[i]);
    }
    return ans;
}
int solve2(){
    vector<pair<int, int> > p; // -1 is right 1 is left
    for(int i = 1; i <= n; i++){
        p.push_back({line[i].l, 1});
        p.push_back({line[i].r, -1});
    }
    sort(p.begin(), p.end());
    int ans = 0, cnt = 0;
    for(auto &i : p){
        cnt += i.second;
        ans = max(ans, cnt);
    }
    return ans;
}
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> line[i].l >> line[i].r;
        line[i].id = i;
    }
    cout << solve1() << ' ' << solve2() << '\n';
}

详细

Test #1:

score: 100
Accepted
time: 2ms
memory: 15840kb

input:

1
1 100000

output:

1 1

result:

ok single line: '1 1'

Test #2:

score: 0
Accepted
time: 71ms
memory: 24912kb

input:

200000
538 540
37 39
708 710
540 541
583 585
224 226
866 868
914 916
405 406
185 187
542 545
335 336
217 220
546 548
952 954
414 415
799 800
826 827
844 846
207 209
967 968
632 635
517 519
581 584
63 64
309 311
146 149
493 494
526 529
589 591
32 33
6 7
486 489
372 373
233 236
278 279
524 525
554 555...

output:

917 467

result:

ok single line: '917 467'

Test #3:

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

input:

1000
89384 89472
92778 92795
47794 47831
85387 85481
16650 16673
2363 2392
68691 68752
97764 97792
80541 80569
89173 89211
5212 5282
2568 2599
65783 65815
22863 22888
74068 74105
13930 13934
34023 34083
33070 33139
61394 61452
75012 75056
76230 76305
84422 84443
13785 13824
75199 75225
98316 98388
6...

output:

6 4

result:

ok single line: '6 4'

Test #4:

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

input:

1000
89384 89472
92778 92895
47794 47931
85387 85481
16650 16673
2363 2392
68691 68752
97764 97892
80541 80569
89173 89311
5212 5382
2568 2599
65783 65915
22863 22988
74068 74205
13930 13934
34023 34083
33070 33239
61394 61452
75012 75056
76230 76405
84422 84543
13785 13924
75199 75325
98316 98488
6...

output:

10 7

result:

ok single line: '10 7'

Test #5:

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

input:

1000
89384 89672
92778 92895
47794 48031
85387 85581
16650 16773
2363 2492
68691 68952
97764 97992
80541 80669
89173 89311
5212 5282
2568 2699
65783 66015
22863 23088
74068 74305
13930 14034
34023 34283
33070 33339
61394 61652
75012 75156
76230 76505
84422 84543
13785 13824
75199 75425
98316 98588
6...

output:

11 7

result:

ok single line: '11 7'

Test #6:

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

input:

1000
89384 89472
92778 92895
47794 48131
85387 85481
16650 16873
2363 2392
68691 68752
97764 98092
80541 80769
89173 89311
5212 5382
2568 2599
65783 66115
22863 23188
74068 74405
13930 14134
34023 34283
33070 33239
61394 61452
75012 75056
76230 76405
84422 84543
13785 13924
75199 75525
98316 98688
6...

output:

13 9

result:

ok single line: '13 9'

Test #7:

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

input:

1000
89384 89772
92778 93195
47794 48131
85387 85881
16650 17073
2363 2392
68691 68752
97764 98192
80541 80969
89173 89411
5212 5582
2568 2999
65783 65815
22863 22988
74068 74205
13930 14234
34023 34083
33070 33239
61394 61852
75012 75056
76230 76605
84422 84843
13785 13824
75199 75525
98316 98688
6...

output:

15 9

result:

ok single line: '15 9'

Test #8:

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

input:

20000
89384 89472
92778 92795
47794 47831
85387 85481
16650 16673
2363 2392
68691 68752
97764 97792
80541 80569
89173 89211
5212 5282
2568 2599
65783 65815
22863 22888
74068 74105
13930 13934
34023 34083
33070 33139
61394 61452
75012 75056
76230 76305
84422 84443
13785 13824
75199 75225
98316 98388
...

output:

50 26

result:

ok single line: '50 26'

Test #9:

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

input:

20000
89384 89472
92778 92895
47794 47931
85387 85481
16650 16673
2363 2392
68691 68752
97764 97892
80541 80569
89173 89311
5212 5382
2568 2599
65783 65915
22863 22988
74068 74205
13930 13934
34023 34083
33070 33239
61394 61452
75012 75056
76230 76405
84422 84543
13785 13924
75199 75325
98316 98488
...

output:

86 39

result:

ok single line: '86 39'

Test #10:

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

input:

20000
89384 89672
92778 92895
47794 48031
85387 85581
16650 16773
2363 2492
68691 68952
97764 97992
80541 80669
89173 89311
5212 5282
2568 2699
65783 66015
22863 23088
74068 74305
13930 14034
34023 34283
33070 33339
61394 61652
75012 75156
76230 76505
84422 84543
13785 13824
75199 75425
98316 98588
...

output:

116 51

result:

ok single line: '116 51'

Test #11:

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

input:

20000
89384 89472
92778 92895
47794 48131
85387 85481
16650 16873
2363 2392
68691 68752
97764 98092
80541 80769
89173 89311
5212 5382
2568 2599
65783 66115
22863 23188
74068 74405
13930 14134
34023 34283
33070 33239
61394 61452
75012 75056
76230 76405
84422 84543
13785 13924
75199 75525
98316 98688
...

output:

150 67

result:

ok single line: '150 67'

Test #12:

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

input:

5
1 100000
1 100000
1 100000
1 100000
1 100000

output:

5 5

result:

ok single line: '5 5'

Test #13:

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

input:

20000
89384 89772
92778 93195
47794 48131
85387 85881
16650 17073
2363 2392
68691 68752
97764 98192
80541 80969
89173 89411
5212 5582
2568 2999
65783 65815
22863 22988
74068 74205
13930 14234
34023 34083
33070 33239
61394 61852
75012 75056
76230 76605
84422 84843
13785 13824
75199 75525
98316 98688
...

output:

180 76

result:

ok single line: '180 76'

Test #14:

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

input:

1000
35291 35312
86789 86866
83062 83162
20865 20944
8746 8775
4343 4424
91150 91245
35038 35089
14655 14730
2368 2400
46003 46077
68570 68587
59768 59861
93211 93243
22297 22362
8014 8102
89783 89787
32162 32260
67653 67732
48474 48573
45358 45427
42929 42937
54261 54328
51557 51573
93091 93168
164...

output:

6 5

result:

ok single line: '6 5'

Test #15:

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

input:

1000
35291 35412
86789 86966
83062 83162
20865 20944
8746 8775
4343 4524
91150 91245
35038 35089
14655 14830
2368 2500
46003 46177
68570 68687
59768 59961
93211 93243
22297 22362
8014 8202
89783 89787
32162 32360
67653 67832
48474 48673
45358 45527
42929 43037
54261 54428
51557 51673
93091 93168
164...

output:

9 6

result:

ok single line: '9 6'

Test #16:

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

input:

1000
35291 35312
86789 87066
83062 83262
20865 21044
8746 8775
4343 4624
91150 91445
35038 35289
14655 14930
2368 2600
46003 46277
68570 68787
59768 59861
93211 93443
22297 22362
8014 8202
89783 89887
32162 32260
67653 67832
48474 48673
45358 45527
42929 43137
54261 54328
51557 51673
93091 93268
164...

output:

11 9

result:

ok single line: '11 9'

Test #17:

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

input:

1000
35291 35612
86789 86966
83062 83162
20865 20944
8746 8775
4343 4524
91150 91445
35038 35289
14655 15030
2368 2700
46003 46377
68570 68887
59768 59961
93211 93243
22297 22562
8014 8402
89783 89787
32162 32560
67653 67832
48474 48873
45358 45727
42929 43037
54261 54628
51557 51673
93091 93368
164...

output:

13 8

result:

ok single line: '13 8'

Test #18:

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

input:

1000
35291 35512
86789 86866
83062 83562
20865 21144
8746 8875
4343 4524
91150 91245
35038 35089
14655 14930
2368 2600
46003 46077
68570 68887
59768 60161
93211 93343
22297 22362
8014 8102
89783 90087
32162 32360
67653 68032
48474 48873
45358 45527
42929 42937
54261 54728
51557 51973
93091 93368
164...

output:

15 10

result:

ok single line: '15 10'

Test #19:

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

input:

20000
35291 35312
86789 86866
83062 83162
20865 20944
8746 8775
4343 4424
91150 91245
35038 35089
14655 14730
2368 2400
46003 46077
68570 68587
59768 59861
93211 93243
22297 22362
8014 8102
89783 89787
32162 32260
67653 67732
48474 48573
45358 45427
42929 42937
54261 54328
51557 51573
93091 93168
16...

output:

51 26

result:

ok single line: '51 26'

Test #20:

score: 0
Accepted
time: 10ms
memory: 16424kb

input:

20000
35291 35412
86789 86966
83062 83162
20865 20944
8746 8775
4343 4524
91150 91245
35038 35089
14655 14830
2368 2500
46003 46177
68570 68687
59768 59961
93211 93243
22297 22362
8014 8202
89783 89787
32162 32360
67653 67832
48474 48673
45358 45527
42929 43037
54261 54428
51557 51673
93091 93168
16...

output:

83 39

result:

ok single line: '83 39'

Test #21:

score: 0
Accepted
time: 14ms
memory: 17784kb

input:

20000
35291 35312
86789 87066
83062 83262
20865 21044
8746 8775
4343 4624
91150 91445
35038 35289
14655 14930
2368 2600
46003 46277
68570 68787
59768 59861
93211 93443
22297 22362
8014 8202
89783 89887
32162 32260
67653 67832
48474 48673
45358 45527
42929 43137
54261 54328
51557 51673
93091 93268
16...

output:

119 53

result:

ok single line: '119 53'

Test #22:

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

input:

20000
35291 35612
86789 86966
83062 83162
20865 20944
8746 8775
4343 4524
91150 91445
35038 35289
14655 15030
2368 2700
46003 46377
68570 68887
59768 59961
93211 93243
22297 22562
8014 8402
89783 89787
32162 32560
67653 67832
48474 48873
45358 45727
42929 43037
54261 54628
51557 51673
93091 93368
16...

output:

152 63

result:

ok single line: '152 63'

Test #23:

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

input:

5
1 100
99 200
199 300
299 400
399 500

output:

3 2

result:

ok single line: '3 2'

Test #24:

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

input:

20000
35291 35512
86789 86866
83062 83562
20865 21144
8746 8875
4343 4524
91150 91245
35038 35089
14655 14930
2368 2600
46003 46077
68570 68887
59768 60161
93211 93343
22297 22362
8014 8102
89783 90087
32162 32360
67653 68032
48474 48873
45358 45527
42929 42937
54261 54728
51557 51973
93091 93368
16...

output:

186 78

result:

ok single line: '186 78'

Test #25:

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

input:

1000
54747 54834
58169 58211
21426 21468
24073 24151
60802 60868
14859 14885
51394 51435
603 646
68265 68342
17202 17299
12516 12560
13439 13499
32274 32323
23886 23925
68469 68569
63455 63471
45137 45213
90007 90070
52916 52996
66291 66361
79695 79745
19993 20082
62889 62938
282 336
13923 14007
174...

output:

6 4

result:

ok single line: '6 4'

Test #26:

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

input:

1000
54747 54934
58169 58211
21426 21568
24073 24251
60802 60868
14859 14985
51394 51535
603 646
68265 68442
17202 17299
12516 12660
13439 13499
32274 32323
23886 24025
68469 68669
63455 63471
45137 45313
90007 90170
52916 52996
66291 66361
79695 79845
19993 20082
62889 63038
282 436
13923 14007
174...

output:

9 7

result:

ok single line: '9 7'

Test #27:

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

input:

1000
54747 54834
58169 58411
21426 21468
24073 24151
60802 60868
14859 14985
51394 51535
603 746
68265 68442
17202 17399
12516 12560
13439 13699
32274 32323
23886 24025
68469 68769
63455 63671
45137 45213
90007 90070
52916 53196
66291 66461
79695 79945
19993 20182
62889 63138
282 336
13923 14007
174...

output:

11 7

result:

ok single line: '11 7'

Test #28:

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

input:

1000
54747 55134
58169 58211
21426 21568
24073 24251
60802 60868
14859 15185
51394 51535
603 646
68265 68442
17202 17499
12516 12860
13439 13499
32274 32523
23886 24025
68469 68869
63455 63471
45137 45513
90007 90170
52916 52996
66291 66361
79695 80045
19993 20282
62889 63038
282 636
13923 14207
174...

output:

13 9

result:

ok single line: '13 9'

Test #29:

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

input:

1000
54747 55234
58169 58611
21426 21868
24073 24451
60802 61068
14859 15285
51394 51635
603 946
68265 68742
17202 17599
12516 12660
13439 13699
32274 32423
23886 24325
68469 68769
63455 63671
45137 45613
90007 90070
52916 52996
66291 66361
79695 79845
19993 20082
62889 63338
282 436
13923 14407
174...

output:

15 9

result:

ok single line: '15 9'

Test #30:

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

input:

20000
54747 54834
58169 58211
21426 21468
24073 24151
60802 60868
14859 14885
51394 51435
603 646
68265 68342
17202 17299
12516 12560
13439 13499
32274 32323
23886 23925
68469 68569
63455 63471
45137 45213
90007 90070
52916 52996
66291 66361
79695 79745
19993 20082
62889 62938
282 336
13923 14007
17...

output:

50 26

result:

ok single line: '50 26'

Test #31:

score: 0
Accepted
time: 14ms
memory: 17388kb

input:

20000
54747 54934
58169 58211
21426 21568
24073 24251
60802 60868
14859 14985
51394 51535
603 646
68265 68442
17202 17299
12516 12660
13439 13499
32274 32323
23886 24025
68469 68669
63455 63471
45137 45313
90007 90170
52916 52996
66291 66361
79695 79845
19993 20082
62889 63038
282 436
13923 14007
17...

output:

87 40

result:

ok single line: '87 40'

Test #32:

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

input:

20000
54747 54834
58169 58411
21426 21468
24073 24151
60802 60868
14859 14985
51394 51535
603 746
68265 68442
17202 17399
12516 12560
13439 13699
32274 32323
23886 24025
68469 68769
63455 63671
45137 45213
90007 90070
52916 53196
66291 66461
79695 79945
19993 20182
62889 63138
282 336
13923 14007
17...

output:

117 56

result:

ok single line: '117 56'

Test #33:

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

input:

20000
54747 55134
58169 58211
21426 21568
24073 24251
60802 60868
14859 15185
51394 51535
603 646
68265 68442
17202 17499
12516 12860
13439 13499
32274 32523
23886 24025
68469 68869
63455 63471
45137 45513
90007 90170
52916 52996
66291 66361
79695 80045
19993 20282
62889 63038
282 636
13923 14207
17...

output:

150 74

result:

ok single line: '150 74'

Test #34:

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

input:

8
1 100
100 200
200 300
300 400
400 500
300 301
399 400
199 201

output:

3 2

result:

ok single line: '3 2'

Test #35:

score: 0
Accepted
time: 9ms
memory: 17644kb

input:

20000
54747 55234
58169 58611
21426 21868
24073 24451
60802 61068
14859 15285
51394 51635
603 946
68265 68742
17202 17599
12516 12660
13439 13699
32274 32423
23886 24325
68469 68769
63455 63671
45137 45613
90007 90070
52916 52996
66291 66361
79695 79845
19993 20082
62889 63338
282 436
13923 14407
17...

output:

186 75

result:

ok single line: '186 75'

Test #36:

score: 0
Accepted
time: 10ms
memory: 15528kb

input:

19999
1 181
181 361
361 541
541 721
721 901
901 1081
1081 1261
1261 1441
1441 1621
1621 1801
1801 1981
1981 2161
2161 2341
2341 2521
2521 2701
2701 2881
2881 3061
3061 3241
3241 3421
3421 3601
3601 3781
3781 3961
3961 4141
4141 4321
4321 4501
4501 4681
4681 4861
4861 5041
5041 5221
5221 5401
5401 55...

output:

110 110

result:

ok single line: '110 110'

Test #37:

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

input:

19999
1 95
95 189
189 283
283 377
377 471
471 565
565 659
659 753
753 847
847 941
941 1035
1035 1129
1129 1223
1223 1317
1317 1411
1411 1505
1505 1599
1599 1693
1693 1787
1787 1881
1881 1975
1975 2069
2069 2163
2163 2257
2257 2351
2351 2445
2445 2539
2539 2633
2633 2727
2727 2821
2821 2915
2915 3009...

output:

210 210

result:

ok single line: '210 210'

Test #38:

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

input:

19999
1 65
65 129
129 193
193 257
257 321
321 385
385 449
449 513
513 577
577 641
641 705
705 769
769 833
833 897
897 961
961 1025
1025 1089
1089 1153
1153 1217
1217 1281
1281 1345
1345 1409
1409 1473
1473 1537
1537 1601
1601 1665
1665 1729
1729 1793
1793 1857
1857 1921
1921 1985
1985 2049
2049 2113...

output:

310 310

result:

ok single line: '310 310'

Test #39:

score: 0
Accepted
time: 9ms
memory: 16824kb

input:

20000
1 10001
10001 20001
20001 30001
30001 40001
40001 50001
50001 60001
60001 70001
70001 80001
80001 90001
90001 100000
9384 9391
2778 2794
7794 7810
5387 5400
6650 6652
2363 2371
8691 8711
7764 7771
541 548
9173 9190
5212 5221
2568 2578
5783 5794
2863 2867
4068 4084
3930 3933
4023 4042
3070 3078...

output:

19991 42

result:

ok single line: '19991 42'

Test #40:

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

input:

20000
1 199
199 397
397 595
595 793
793 991
991 1189
1189 1387
1387 1585
1585 1783
1783 1981
1981 2179
2179 2377
2377 2575
2575 2773
2773 2971
2971 3169
3169 3367
3367 3565
3565 3763
3763 3961
3961 4159
4159 4357
4357 4555
4555 4753
4753 4951
4951 5149
5149 5347
5347 5545
5545 5743
5743 5941
5941 61...

output:

100 100

result:

ok single line: '100 100'

Test #41:

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

input:

20000
1 6667
6667 13333
13333 19999
19999 26665
26665 33331
33331 39997
39997 46663
46663 53329
53329 59995
59995 66661
66661 73327
73327 79993
79993 86659
86659 93325
93325 99991
99991 100000
9384 9391
2778 2794
7794 7810
5387 5400
6650 6652
2363 2371
8691 8711
7764 7771
541 548
9173 9190
5212 5221...

output:

13339 43

result:

ok single line: '13339 43'

Test #42:

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

input:

20000
1 100
100 199
199 298
298 397
397 496
496 595
595 694
694 793
793 892
892 991
991 1090
1090 1189
1189 1288
1288 1387
1387 1486
1486 1585
1585 1684
1684 1783
1783 1882
1882 1981
1981 2080
2080 2179
2179 2278
2278 2377
2377 2476
2476 2575
2575 2674
2674 2773
2773 2872
2872 2971
2971 3070
3070 31...

output:

200 200

result:

ok single line: '200 200'

Test #43:

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

input:

20000
1 5001
5001 10001
10001 15001
15001 20001
20001 25001
25001 30001
30001 35001
35001 40001
40001 45001
45001 50001
50001 55001
55001 60001
60001 65001
65001 70001
70001 75001
75001 80001
80001 85001
85001 90001
90001 95001
95001 100000
9384 9391
2778 2794
7794 7810
5387 5400
6650 6652
2363 2371...

output:

10008 44

result:

ok single line: '10008 44'

Test #44:

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

input:

20000
1 67
67 133
133 199
199 265
265 331
331 397
397 463
463 529
529 595
595 661
661 727
727 793
793 859
859 925
925 991
991 1057
1057 1123
1123 1189
1189 1255
1255 1321
1321 1387
1387 1453
1453 1519
1519 1585
1585 1651
1651 1717
1717 1783
1783 1849
1849 1915
1915 1981
1981 2047
2047 2113
2113 2179...

output:

300 300

result:

ok single line: '300 300'

Test #45:

score: 0
Accepted
time: 38ms
memory: 23432kb

input:

200000
1 100000
1 100000
1 100000
1 100000
1 100000
1 100000
1 100000
1 100000
1 100000
1 100000
1 100000
1 100000
1 100000
1 100000
1 100000
1 100000
1 100000
1 100000
1 100000
1 100000
1 100000
1 100000
1 100000
1 100000
1 100000
1 100000
1 100000
1 100000
1 100000
1 100000
1 100000
1 100000
1 100...

output:

200000 200000

result:

ok single line: '200000 200000'

Test #46:

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

input:

19999
1 182
179 360
357 538
535 716
713 894
891 1072
1069 1250
1247 1428
1425 1606
1603 1784
1781 1962
1959 2140
2137 2318
2315 2496
2493 2674
2671 2852
2849 3030
3027 3208
3205 3386
3383 3564
3561 3742
3739 3920
3917 4098
4095 4276
4273 4454
4451 4632
4629 4810
4807 4988
4985 5166
5163 5344
5341 55...

output:

330 220

result:

ok single line: '330 220'

Test #47:

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

input:

19999
1 98
95 192
189 286
283 380
377 474
471 568
565 662
659 756
753 850
847 944
941 1038
1035 1132
1129 1226
1223 1320
1317 1414
1411 1508
1505 1602
1599 1696
1693 1790
1787 1884
1881 1978
1975 2072
2069 2166
2163 2260
2257 2354
2351 2448
2445 2542
2539 2636
2633 2730
2727 2824
2821 2918
2915 3012...

output:

630 420

result:

ok single line: '630 420'

Test #48:

score: 0
Accepted
time: 9ms
memory: 16644kb

input:

19999
1 68
65 132
129 196
193 260
257 324
321 388
385 452
449 516
513 580
577 644
641 708
705 772
769 836
833 900
897 964
961 1028
1025 1092
1089 1156
1153 1220
1217 1284
1281 1348
1345 1412
1409 1476
1473 1540
1537 1604
1601 1668
1665 1732
1729 1796
1793 1860
1857 1924
1921 1988
1985 2052
2049 2116...

output:

930 620

result:

ok single line: '930 620'

Test #49:

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

input:

20000
1 6670
6667 13336
13333 20002
19999 26668
26665 33334
33331 40000
39997 46666
46663 53332
53329 59998
59995 66664
66661 73330
73327 79996
79993 86662
86659 93328
93325 99994
99991 100000
9384 9391
2778 2794
7794 7810
5387 5400
6650 6652
2363 2371
8691 8711
7764 7771
541 548
9173 9190
5212 5221...

output:

13358 42

result:

ok single line: '13358 42'

Test #50:

score: 0
Accepted
time: 10ms
memory: 16964kb

input:

20000
1 200
197 396
393 592
589 788
785 984
981 1180
1177 1376
1373 1572
1569 1768
1765 1964
1961 2160
2157 2356
2353 2552
2549 2748
2745 2944
2941 3140
3137 3336
3333 3532
3529 3728
3725 3924
3921 4120
4117 4316
4313 4512
4509 4708
4705 4904
4901 5100
5097 5296
5293 5492
5489 5688
5685 5884
5881 60...

output:

300 200

result:

ok single line: '300 200'

Test #51:

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

input:

20000
1 5004
5001 10004
10001 15004
15001 20004
20001 25004
25001 30004
30001 35004
35001 40004
40001 45004
45001 50004
50001 55004
55001 60004
60001 65004
65001 70004
70001 75004
75001 80004
80001 85004
85001 90004
90001 95004
95001 100000
9384 9391
2778 2794
7794 7810
5387 5400
6650 6652
2363 2371...

output:

10025 43

result:

ok single line: '10025 43'

Test #52:

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

input:

20000
1 103
100 202
199 301
298 400
397 499
496 598
595 697
694 796
793 895
892 994
991 1093
1090 1192
1189 1291
1288 1390
1387 1489
1486 1588
1585 1687
1684 1786
1783 1885
1882 1984
1981 2083
2080 2182
2179 2281
2278 2380
2377 2479
2476 2578
2575 2677
2674 2776
2773 2875
2872 2974
2971 3073
3070 31...

output:

600 400

result:

ok single line: '600 400'

Test #53:

score: 0
Accepted
time: 14ms
memory: 16680kb

input:

20000
1 4004
4001 8004
8001 12004
12001 16004
16001 20004
20001 24004
24001 28004
28001 32004
32001 36004
36001 40004
40001 44004
44001 48004
48001 52004
52001 56004
56001 60004
60001 64004
64001 68004
68001 72004
72001 76004
76001 80004
80001 84004
84001 88004
88001 92004
92001 96004
96001 100000
9...

output:

8013 44

result:

ok single line: '8013 44'

Test #54:

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

input:

20000
1 70
67 136
133 202
199 268
265 334
331 400
397 466
463 532
529 598
595 664
661 730
727 796
793 862
859 928
925 994
991 1060
1057 1126
1123 1192
1189 1258
1255 1324
1321 1390
1387 1456
1453 1522
1519 1588
1585 1654
1651 1720
1717 1786
1783 1852
1849 1918
1915 1984
1981 2050
2047 2116
2113 2182...

output:

900 600

result:

ok single line: '900 600'

Test #55:

score: 0
Accepted
time: 9ms
memory: 16940kb

input:

19999
1 745
177 1464
353 811
529 1445
705 1939
881 1777
1057 2444
1233 2846
1409 3019
1585 2687
1761 2364
1937 3485
2113 3604
2289 3789
2465 3749
2641 3768
2817 4158
2993 4500
3169 4822
3345 4842
3521 4093
3697 3706
3873 5001
4049 4479
4225 5528
4401 5772
4577 5040
4753 5237
4929 6517
5105 6161
5281...

output:

1636 646

result:

ok single line: '1636 646'

Test #56:

score: 0
Accepted
time: 37ms
memory: 23688kb

input:

200000
1 50000
1 100000
1 100000
1 100000
1 100000
1 100000
1 100000
1 100000
1 100000
1 100000
1 100000
1 100000
1 100000
1 100000
1 100000
1 100000
1 100000
1 100000
1 100000
1 100000
1 100000
1 100000
1 100000
1 100000
1 100000
1 100000
1 100000
1 100000
1 100000
1 100000
1 100000
1 100000
1 1000...

output:

200000 199999

result:

ok single line: '200000 199999'

Test #57:

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

input:

19999
1 105
94 441
187 935
280 846
373 517
466 702
559 846
652 665
745 1445
838 1140
931 1054
1024 1782
1117 1978
1210 1620
1303 2047
1396 1743
1489 1550
1582 1829
1675 2238
1768 2055
1861 1873
1954 2173
2047 2495
2140 2510
2233 2386
2326 2887
2419 2422
2512 3276
2605 3333
2698 3504
2791 3331
2884 3...

output:

3085 1195

result:

ok single line: '3085 1195'

Test #58:

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

input:

19999
1 255
64 531
127 515
190 756
253 367
316 432
379 516
442 725
505 1025
568 1020
631 844
694 1302
757 988
820 1350
883 1177
946 1563
1009 1160
1072 1109
1135 1278
1198 1425
1261 1783
1324 1423
1387 1925
1450 1880
1513 1936
1576 2107
1639 1792
1702 1716
1765 1893
1828 1974
1891 2401
1954 2207
201...

output:

4514 1724

result:

ok single line: '4514 1724'

Test #59:

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

input:

20000
1 20001
5001 25001
10001 30001
15001 35001
20001 40001
25001 45001
30001 50001
35001 55001
40001 60001
45001 65001
50001 70001
55001 75001
60001 80001
65001 85001
70001 90001
75001 95001
80001 100000
85001 100000
90001 100000
95001 100000
9384 9391
2778 2794
7794 7810
5387 5400
6650 6652
2363 ...

output:

19984 42

result:

ok single line: '19984 42'

Test #60:

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

input:

20000
1 145
195 802
389 2227
583 1479
777 1451
971 2047
1165 2992
1359 1372
1553 3123
1747 2189
1941 3544
2135 3843
2329 2900
2523 3123
2717 2741
2911 3758
3105 3706
3299 3446
3493 5426
3687 4464
3881 5673
4075 5224
4269 5317
4463 5873
4657 6540
4851 5882
5045 6168
5239 7063
5433 7041
5627 6703
5821...

output:

1484 584

result:

ok single line: '1484 584'

Test #61:

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

input:

20000
1 9385
4001 14888
8001 20779
12001 48917
16001 43795
20001 58337
24001 29388
28001 28494
32001 68651
36001 37423
40001 42364
44001 54029
48001 56692
52001 52061
56001 73765
60001 93928
64001 84542
68001 91428
72001 81174
76001 91738
80001 85213
84001 100000
88001 100000
92001 100000
96001 1000...

output:

19966 41

result:

ok single line: '19966 41'

Test #62:

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

input:

20000
1 605
99 286
197 235
295 791
393 1207
491 747
589 1496
687 760
785 1235
883 1685
981 1824
1079 1127
1177 1968
1275 1735
1373 1737
1471 1738
1569 1930
1667 2474
1765 1838
1863 2720
1961 2553
2059 2228
2157 3045
2255 2685
2353 2776
2451 2842
2549 2632
2647 3431
2745 2873
2843 3339
2941 3731
3039...

output:

2952 1152

result:

ok single line: '2952 1152'

Test #63:

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

input:

20000
1 3165
3334 18921
6667 34295
10000 18396
13333 23587
16666 30762
19999 44046
23332 48815
26665 36305
29998 57060
33331 38224
36664 61752
39997 53698
43330 73650
46663 48937
49996 60693
53329 70400
56662 60809
59995 79578
63328 82755
66661 75373
69994 84193
73327 100000
76660 100000
79993 10000...

output:

19937 50

result:

ok single line: '19937 50'

Test #64:

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

input:

20000
1 525
67 474
133 371
199 675
265 619
331 567
397 684
463 536
529 599
595 597
661 1264
727 735
793 964
859 1479
925 1549
991 1458
1057 1298
1123 1310
1189 1302
1255 1872
1321 1453
1387 1396
1453 1481
1519 1949
1585 2008
1651 1702
1717 1960
1783 1827
1849 2337
1915 2091
1981 2311
2047 2330
2113 ...

output:

4394 1694

result:

ok single line: '4394 1694'

Test #65:

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

input:

10
1 10
9 21
20 30
1 10
9 21
20 30
1 10
9 21
20 30
1 10

output:

10 7

result:

ok single line: '10 7'

Test #66:

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

input:

10
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2

output:

10 10

result:

ok single line: '10 10'

Test #67:

score: 0
Accepted
time: 130ms
memory: 28580kb

input:

200000
43513 43515
43229 43231
6528 6530
6984 6985
34545 34547
33119 33121
92190 92192
59111 59113
21497 21498
98293 98295
6262 6265
11409 11410
75875 75878
31224 31226
38424 38426
46975 46976
73491 73492
74143 74144
93191 93193
93855 93857
10166 10167
10207 10210
32037 32039
27237 27240
2810 2811
3...

output:

23 15

result:

ok single line: '23 15'

Test #68:

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

input:

1000
1 10
9 21
20 30
1 10
9 21
20 30
1 10
9 21
20 30
1 10
9 21
20 30
1 10
9 21
20 30
1 10
9 21
20 30
1 10
9 21
20 30
1 10
9 21
20 30
1 10
9 21
20 30
1 10
9 21
20 30
1 10
9 21
20 30
1 10
9 21
20 30
1 10
9 21
20 30
1 10
9 21
20 30
1 10
9 21
20 30
1 10
9 21
20 30
1 10
9 21
20 30
1 10
9 21
20 30
1 10
9 ...

output:

1000 667

result:

ok single line: '1000 667'

Test #69:

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

input:

1
1 2

output:

1 1

result:

ok single line: '1 1'

Test #70:

score: 0
Accepted
time: 30ms
memory: 23788kb

input:

200000
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1...

output:

200000 200000

result:

ok single line: '200000 200000'

Test #71:

score: 0
Accepted
time: 31ms
memory: 24872kb

input:

200000
1 10
9 21
20 30
1 10
9 21
20 30
1 10
9 21
20 30
1 10
9 21
20 30
1 10
9 21
20 30
1 10
9 21
20 30
1 10
9 21
20 30
1 10
9 21
20 30
1 10
9 21
20 30
1 10
9 21
20 30
1 10
9 21
20 30
1 10
9 21
20 30
1 10
9 21
20 30
1 10
9 21
20 30
1 10
9 21
20 30
1 10
9 21
20 30
1 10
9 21
20 30
1 10
9 21
20 30
1 10
...

output:

200000 133334

result:

ok single line: '200000 133334'

Test #72:

score: 0
Accepted
time: 31ms
memory: 23504kb

input:

200000
1 10
9 21
20 30
99999 100000
1 10
9 21
20 30
99999 100000
1 10
9 21
20 30
99999 100000
1 10
9 21
20 30
99999 100000
1 10
9 21
20 30
99999 100000
1 10
9 21
20 30
99999 100000
1 10
9 21
20 30
99999 100000
1 10
9 21
20 30
99999 100000
1 10
9 21
20 30
99999 100000
1 10
9 21
20 30
99999 100000
1 1...

output:

150000 100000

result:

ok single line: '150000 100000'

Test #73:

score: 0
Accepted
time: 32ms
memory: 23432kb

input:

200000
1 2
3 4
1 2
3 4
1 2
3 4
1 2
3 4
1 2
3 4
1 2
3 4
1 2
3 4
1 2
3 4
1 2
3 4
1 2
3 4
1 2
3 4
1 2
3 4
1 2
3 4
1 2
3 4
1 2
3 4
1 2
3 4
1 2
3 4
1 2
3 4
1 2
3 4
1 2
3 4
1 2
3 4
1 2
3 4
1 2
3 4
1 2
3 4
1 2
3 4
1 2
3 4
1 2
3 4
1 2
3 4
1 2
3 4
1 2
3 4
1 2
3 4
1 2
3 4
1 2
3 4
1 2
3 4
1 2
3 4
1 2
3 4
1 2
3...

output:

100000 100000

result:

ok single line: '100000 100000'

Test #74:

score: 0
Accepted
time: 58ms
memory: 24308kb

input:

200000
47 49
92 94
92 94
81 82
18 20
51 53
86 88
24 26
19 20
90 92
46 49
78 79
40 43
56 58
56 58
69 70
34 35
89 90
5 7
5 7
60 61
14 17
6 8
53 56
52 53
56 58
61 64
52 53
30 33
80 82
49 50
55 56
79 82
74 75
83 86
39 40
66 67
27 28
54 57
29 32
89 90
8 11
53 54
85 88
33 35
4 5
51 52
97 99
3 4
49 52
85 8...

output:

8423 4264

result:

ok single line: '8423 4264'

Test #75:

score: 0
Accepted
time: 90ms
memory: 25104kb

input:

200000
833 835
7435 7437
5293 5295
1417 1418
5657 5659
16 18
3771 3773
1417 1419
218 219
427 429
5715 5718
1005 1006
6751 6754
6503 6505
7811 7813
4482 4483
8829 8830
3932 3933
9475 9477
3520 3522
5683 5684
2344 2347
6362 6364
5726 5729
3268 3269
5384 5386
9959 9962
3656 3657
8215 8218
1957 1959
586...

output:

117 66

result:

ok single line: '117 66'