QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#143404#6703. Tokens on the Segmentsqzez#WA 84ms4420kbC++141.1kb2023-08-21 10:59:242023-08-21 10:59:26

Judging History

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

  • [2023-08-21 10:59:26]
  • 评测
  • 测评结果:WA
  • 用时:84ms
  • 内存:4420kb
  • [2023-08-21 10:59:24]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
template<typename T>
ostream& operator << (ostream &out,const vector<T>&x){
	if(x.empty())return out<<"[]";
	out<<'['<<x[0];
	for(int len=x.size(),i=1;i<len;i++)out<<','<<x[i];
	return out<<']';
}
template<typename T>
vector<T> ary(const T *a,int l,int r){
	return vector<T>{a+l,a+1+r};
}
template<typename T>
void debug(T x){
	cerr<<x<<'\n';
}
template<typename T,typename ...S>
void debug(T x,S ...y){
	cerr<<x<<' ',debug(y...);
}
const int N=1e5+10;
int T,n;
struct seg{
    int l,r;
}a[N];
void get(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++)scanf("%d%d",&a[i].l,&a[i].r);
    sort(a+1,a+1+n,[](seg x,seg y){
        return x.l<y.l;
    });
    int ans=0;
    priority_queue<int,vector<int>,greater<int> >q;
    a[n+1].l=1e9;
    for(int i=1,x=0;i<=n;i++){
        x=max(x,a[i].l);
        q.push(a[i].r);
        for(int cnt=a[i+1].l-a[i].l;cnt--&&!q.empty();){
            int y=q.top();
            q.pop();
            if(x<=y)ans++,x++;
        }
    }
    printf("%d\n",ans);
}
int main(){
    for(scanf("%d",&T);T--;)get();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3780kb

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: 84ms
memory: 4420kb

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:

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

result:

wrong answer 14th numbers differ - expected: '18', found: '17'