QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#108218#6334. Passportikaurov#6 18ms3892kbC++17854b2023-05-23 21:41:552024-05-31 13:42:05

Judging History

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

  • [2024-05-31 13:42:05]
  • 评测
  • 测评结果:6
  • 用时:18ms
  • 内存:3892kb
  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-23 21:41:55]
  • 提交

answer

#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define all(arr) (arr).begin(), (arr).end()
#define ll long long
#define ld long double
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second
#define endl '\n'

signed main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  // cout.precision(20);
  int n;
  cin >> n;
  vector<int> r(n);
  for (int i = 0; i < n; i++){
    int x, y;
    cin >> x >> y;
    y--;
    r[i] = y;
  }
  int q, foo;
  cin >> q >> foo;
  int prevrb = -1, rb = r[0], ans = 1;
  while (rb < n - 1){
    int newrb = rb;
    for (int i = prevrb + 1; i <= rb; i++){
      newrb = max(newrb, r[i]);
    }
    if (newrb == rb){
      cout << -1 << endl;
      return 0;
    }
    prevrb = rb, rb = newrb, ans++;
  }
  cout << ans << endl;
}

详细

Subtask #1:

score: 6
Accepted

Test #1:

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

input:

2
1 1
1 2
1
1

output:

-1

result:

ok single line: '-1'

Test #2:

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

input:

2
1 2
2 2
1
1

output:

1

result:

ok single line: '1'

Test #3:

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

input:

196001
1 408
2 37822
1 1221
1 160899
4 62751
3 21706
2 4118
8 70696
8 4916
3 24286
9 443
8 171744
11 170980
7 3541
12 16428
8 71164
1 186827
11 234
2 23141
4 17143
21 9522
10 24
19 15936
3 15884
17 426
14 3188
17 168317
4 1560
25 35
16 39439
21 122
4 17507
8 97645
11 824
25 59856
30 9265
7 151420
37...

output:

3

result:

ok single line: '3'

Test #4:

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

input:

198001
1 17
1 19
1 4
2 20
3 15
6 10
1 20
3 9
3 9
10 19
6 27
8 29
12 24
3 23
8 23
16 19
11 23
1 19
13 30
19 32
4 28
15 33
23 33
8 36
16 30
23 40
11 42
27 34
20 30
21 36
31 39
30 35
32 33
29 48
27 43
33 41
25 53
28 51
29 56
37 55
35 54
36 52
35 44
31 58
36 54
42 56
47 49
41 59
37 64
44 50
34 55
41 56
...

output:

15219

result:

ok single line: '15219'

Test #5:

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

input:

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

output:

199999

result:

ok single line: '199999'

Test #6:

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

input:

195000
1 195000
1 195000
1 195000
1 195000
1 195000
1 195000
1 195000
1 195000
1 195000
1 195000
1 195000
1 195000
1 195000
1 195000
1 195000
1 195000
1 195000
1 195000
1 195000
1 195000
1 195000
1 195000
1 195000
1 195000
1 195000
1 195000
1 195000
1 195000
1 195000
1 195000
1 195000
1 195000
1 195...

output:

1

result:

ok single line: '1'

Test #7:

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

input:

156789
1 78394
1 78394
1 78394
1 78394
1 78394
1 78394
1 78394
1 78394
1 78394
1 78394
1 78394
1 78394
1 78394
1 78394
1 78394
1 78394
1 78394
1 78394
1 78394
1 78394
1 78394
1 78394
1 78394
1 78394
1 78394
1 78394
1 78394
1 78394
1 78394
1 78394
1 78394
1 78394
1 78394
1 78394
1 78394
1 78394
1 783...

output:

-1

result:

ok single line: '-1'

Subtask #2:

score: 0
Wrong Answer

Test #8:

score: 0
Wrong Answer
time: 0ms
memory: 3824kb

input:

2
1 1
1 2
1
2

output:

-1

result:

wrong answer 1st lines differ - expected: '1', found: '-1'

Subtask #3:

score: 0
Wrong Answer

Test #19:

score: 0
Wrong Answer
time: 1ms
memory: 3536kb

input:

2337
1 3
2 77
1 1397
2 222
3 62
6 1896
7 10
6 950
9 9
10 16
11 455
9 588
13 16
7 1245
9 1342
8 1727
7 122
11 653
9 1094
2 57
11 81
19 1290
6 1584
16 79
14 215
21 61
27 27
16 1458
16 198
26 180
31 31
11 240
33 36
11 121
34 1542
9 1752
14 456
36 43
36 2244
40 40
4 517
42 662
31 1350
33 162
30 843
28 1...

output:

3

result:

wrong answer 1st lines differ - expected: '4', found: '3'

Subtask #4:

score: 0
Wrong Answer

Test #28:

score: 0
Wrong Answer
time: 1ms
memory: 3540kb

input:

2419
1 883
1 29
3 41
4 2201
1 808
6 45
7 1456
6 134
6 1372
1 1776
4 441
7 208
5 28
4 604
7 56
9 617
8 2115
15 60
13 456
10 2071
18 23
18 39
5 39
21 35
4 75
25 44
24 640
21 30
4 860
30 31
18 78
32 779
1 927
33 34
19 59
34 181
21 502
23 155
39 39
2 254
30 641
42 50
10 2000
41 2220
18 632
35 48
27 905
...

output:

3

result:

wrong answer 2nd lines differ - expected: '3', found: ''

Subtask #5:

score: 0
Wrong Answer

Test #33:

score: 0
Wrong Answer
time: 18ms
memory: 3836kb

input:

196830
1 67357
2 183304
3 23390
4 54
1 145887
3 27807
3 12376
1 1013
3 113274
3 191874
6 23342
9 2113
13 94245
3 141449
10 1727
3 51
17 99028
6 193803
8 7452
6 121537
9 23658
18 611
6 4756
4 5141
8 8547
8 66922
13 7021
9 72
3 53043
16 167381
2 15530
5 192
33 33
9 92655
10 36182
20 19992
36 24454
1 6...

output:

3

result:

wrong answer 2nd lines differ - expected: '3', found: ''