QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#92660 | #4393. Snatch Groceries | zbceyond# | AC ✓ | 55ms | 4960kb | C++20 | 958b | 2023-03-30 20:24:09 | 2023-03-30 20:24:11 |
Judging History
answer
#include<bits/stdc++.h>
#define rep(i,x,y) for(int i=x;i<=y;i++)
#define per(i,x,y) for(int i=x;i>=y;i--)
using namespace std;
const int N=6e6+10;
const int mod=998244353;
#define int long long
int qmi(int a,int b,int mod){//mod别弄错了
int res=1;
for(;b;b>>=1,a=a*a%mod)
if(b&1)res=res*a%mod;
return res;
}
void solve() {
int n;cin>>n;
vector<array<int,2>>x(n+1);
rep(i,1,n)cin>>x[i][0]>>x[i][1];
sort(x.begin()+1,x.end());
int las=-1,ans=0;
rep(i,1,n){
auto [l,r]=x[i];
if(l<=las){
cout<<ans<<"\n";
return;
}
else {
if(i!=1)ans++;
las=r;
}
}
cout<<ans+1<<"\n";
}
signed main() {
cin.tie(nullptr)->sync_with_stdio(false);
int tc = 1;
cin >> tc;
for (int i = 1; i <= tc; i++) {
solve();
}
}
//2
//3
//1 2
//3 4
//5 6
//3
//1 2
//2 3
//1 5
详细
Test #1:
score: 100
Accepted
time: 55ms
memory: 4960kb
input:
5 3 1 2 3 4 5 6 3 1 2 3 4 4 5 100000 263324740 263324748 920719069 920719077 82595123 82595132 765796214 765796222 621714954 621714959 77799324 77799332 278166427 278166428 375391536 375391545 856576804 856576812 512542774 512542781 829984452 829984457 302442403 302442404 779239984 779239986 1189173...
output:
3 1 275 5575 10000
result:
ok 5 lines