QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#302942 | #7953. Product Delivery | OOBMABTRAMS# | WA | 1ms | 5712kb | C++17 | 1002b | 2024-01-11 15:50:11 | 2024-01-11 15:50:12 |
Judging History
answer
#import"bits/stdc++.h"
using namespace std;
typedef long long ll;
void solve();
int main(){
ios::sync_with_stdio(false);
int T=1;
// cin>>T;
while(T--)solve();
}
const int N=3000013;
vector<int>li;
int tr[N];
void add(int x,int v){
for(;x<N;x+=x&-x)tr[x]=max(tr[x],v);
}
int qry(int x){int rs=0;
for(;x;x-=x&-x)rs=max(rs,tr[x]);
return rs;
}
int get(int x){
return std::lower_bound(li.begin(), li.end(), x)-li.begin()+1;
}
int l[N],r[N];
void solve(){
int n;
cin>>n;
for(int i=1;i<=n;i++)cin>>l[i]>>r[i],l[i]=1e9+1-l[i],r[i]=1e9+1-r[i],swap(l[i],r[i]);
for(int i=1;i<=n;i++)li.push_back(l[i]),li.push_back(r[i]);
std::sort(li.begin(), li.end());
li.resize(std::unique(li.begin(), li.end())-li.begin());
for(int i=1;i<=n;i++)l[i]=get(l[i]),r[i]=get(r[i]);
int ans=0;
for(int i=1;i<=n;i++){
int v= qry(l[i]-1);
add(r[i],v+1);
ans=max(v+1,ans);
}
cout<<ans<<'\n';
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 5712kb
input:
4 13 15 5 8 6 14 3 7
output:
2
result:
ok single line: '2'
Test #2:
score: 0
Accepted
time: 1ms
memory: 5696kb
input:
5 1 2 2 3 33 44 4 5 6 7
output:
2
result:
ok single line: '2'
Test #3:
score: -100
Wrong Answer
time: 1ms
memory: 5656kb
input:
5 10 20 3 6 13 30 7 8 11 13
output:
2
result:
wrong answer 1st lines differ - expected: '3', found: '2'