QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#591939#6703. Tokens on the SegmentsFoedere0WA 111ms10784kbC++141019b2024-09-26 19:11:532024-09-26 19:11:54

Judging History

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

  • [2024-09-26 19:11:54]
  • 评测
  • 测评结果:WA
  • 用时:111ms
  • 内存:10784kb
  • [2024-09-26 19:11:53]
  • 提交

answer

#include <bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
typedef pair<int, int> PII;
const int N = 1000010;
unordered_map<int, int> mp;
PII q[N];
void solve()
{
    int n;
    cin >> n;
    priority_queue<PII, vector<PII>, greater<PII>> heap;
    for (int i = 1; i <= n; i++)
    {
        cin >> q[i].first >> q[i].second;
        heap.push(q[i]);
    }
    int res = 0;
    int now = 0;
    while (heap.size())
    {
        int l = heap.top().second, r = heap.top().second;
        if (now < l)
            now = l;
        for (int i = now; i <= r; i++)
        {
            if (!mp[i])
            {
                mp[i] = 1;
                res++;
                break;
            }
        }
        heap.pop();
    }
    cout << res << endl;
    mp.clear();
}
signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int T = 1;
    cin >> T;
    while (T--)
    {
        solve();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

2
3
1 2
1 1
2 3
3
1 2
1 1
2 2

output:

3
2

result:

ok 2 number(s): "3 2"

Test #2:

score: -100
Wrong Answer
time: 111ms
memory: 10784kb

input:

10000
6
5 19
7 12
10 10
4 14
1 12
5 11
7
3 5
1 10
12 15
2 13
8 11
5 20
11 14
18
6 17
6 9
6 20
2 7
1 11
16 19
2 5
1 14
5 8
14 19
4 7
11 19
11 13
2 9
3 12
12 13
19 19
13 16
11
11 13
1 2
14 17
15 16
12 17
15 17
6 7
8 11
12 19
3 8
10 19
18
6 9
16 18
13 15
14 15
9 13
2 8
12 18
8 16
16 18
3 18
1 12
4 13
1...

output:

3
3
4
4
3
2
4
3
3
2
2
2
3
7
4
7
4
7
3
5
7
3
2
4
7
3
4
2
3
1
4
5
3
2
6
4
3
4
3
3
2
3
5
4
4
1
4
3
7
4
4
3
3
2
4
4
1
1
3
2
1
2
4
2
3
5
5
3
2
2
2
4
3
1
1
3
2
6
2
1
4
4
2
4
3
1
4
2
2
2
6
3
5
6
1
4
5
3
1
3
2
2
5
3
2
4
3
2
4
4
3
2
4
3
5
1
6
2
4
4
5
2
4
3
3
6
5
2
4
5
1
4
6
3
4
2
1
3
3
5
5
3
3
1
3
3
2
5
3
4
...

result:

wrong answer 1st numbers differ - expected: '6', found: '3'