QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#612676#8247. ICPC Team GenerationAmy621WA 0ms3608kbC++141.2kb2024-10-05 12:32:032024-10-05 12:32:05

Judging History

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

  • [2024-10-05 12:32:05]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3608kb
  • [2024-10-05 12:32:03]
  • 提交

answer

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef long double ld;
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <limits>
#include <unordered_map>
#include <set>
#include <numeric>
#include <iomanip>
 
int main() {
    // Number of people
    int n; 
    cin >> n;
    vector<pair<int, int>> ranges; // to store (a, b) pairs

    // Read input ranges
    for (int i = 1; i <= n; i++) {
        int a, b; 
        cin >> a >> b;
        if (b - a < 2) continue; // skip ranges that can't form a team
        ranges.push_back(make_pair(a, b));
    }

    // sort ranges by their starting point
    sort(ranges.begin(), ranges.end());

    int count = 0; 
    int i = 0;


    while (i < ranges.size()) {
        int a_check = ranges[i].first; // a
        int b_check = ranges[i].second; // b
        
   
        if (i + 2 < ranges.size() && ranges[i + 2].first <= b_check) {
          
            count++;
            i += 3; 
        } else {
        
            i++;
        }
    }


    cout << count << "\n";
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

6
1 2
1 2
2 5
2 6
2 6
5 6

output:

1

result:

ok single line: '1'

Test #2:

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

input:

3
1 1
2 2
3 3

output:

0

result:

ok single line: '0'

Test #3:

score: -100
Wrong Answer
time: 0ms
memory: 3512kb

input:

50
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 50

output:

16

result:

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