QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#414272#6703. Tokens on the SegmentsxiaoleWA 87ms5316kbC++23913b2024-05-18 19:07:232024-05-18 19:07:24

Judging History

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

  • [2024-05-18 19:07:24]
  • 评测
  • 测评结果:WA
  • 用时:87ms
  • 内存:5316kb
  • [2024-05-18 19:07:23]
  • 提交

answer

#include<bits/stdc++.h>
#define ios ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
using namespace std;using ll = long long;using PLL = pair<ll,ll>;
const ll MAX = 1e18;const ll MIN = -1e18;const ll INF=0x3f3f3f3f;
const ll Q = 2e5+9;const ll MOD = 1e9 + 7;
vector<pair<ll,ll>> v;
bool cmp(pair<ll,ll> l,pair<ll,ll> r){
    if(l.first==r.first) return l.second<r.second;
    return l.first<r.first;
}
void solve(){
    v.clear();
   ll n;cin>>n;
   for (ll i = 0; i < n; i++)
   {
    ll o,p;cin>>o>>p;
    v.push_back({o,p});
   }
   ll cnt=-1;ll ans=0;
   sort(v.begin(),v.end(),cmp);
   for (ll i = 0; i < n; i++)
   {
        if(v[i].first>=cnt){
            cnt=v[i].first+1;
            ans++;
        }else {
            if(v[i].second>=cnt) cnt++,ans++;
        }
   }
   
   cout<<ans<<"\n";
}
int main(){
    ios;ll _=1;cin>>_;
    while (_--)solve();
    return 0;
}

詳細信息

Test #1:

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

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: 87ms
memory: 5316kb

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
17
11
18
11
8
15
15
3
4
5
9
16
14
18
16
12
8
16
15
15
11
15
11
12
4
13
13
3
5
14
9
3
17
8
8
13
7
17
4
11
17
17
6
13
14
12
15
10
6
6
11
7
12
12
17
3
13
16
14
13
7
6
6
11
13
11
3
5
3
4
10
6
3
7
18
12
13
4
9
8
14
18
10
11
10
8
4
18
16
8
16
10
14
17
13
11
6
15
14
18
10
5
8
8
9
15
8
13
14
14
13
16
16...

result:

wrong answer 3rd numbers differ - expected: '18', found: '17'