QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#201583 | #5159. Justice Served | Vengeful_Spirit# | WA | 122ms | 8808kb | C++14 | 1.2kb | 2023-10-05 15:16:25 | 2023-10-05 15:16:25 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N=200005;
struct seg{
int l,r;
}t[N];
int n,nn;
int c[2*N];
void modify(int x,int res){
x=nn-x;
for(;x<=nn;x+=x&(-x)){
c[x]=max(c[x],res);
}
}
int query(int x){
int res=0;
x=nn-x;
for(;x;x-=x&(-x)){
res=max(res,c[x]);
}
return res;
}
int res[N];
int main(){
scanf("%d",&n);
vector<int>s;
for(int i=1;i<=n;i++){
int l,r;
scanf("%d%d",&l,&r);
r=l+r;
s.push_back(l);
s.push_back(r);
t[i]={l,r};
}
sort(s.begin(),s.end());
s.erase(unique(s.begin(),s.end()),s.end());
nn=s.size()+1;
for(int i=1;i<=n;i++){
t[i].l=lower_bound(s.begin(),s.end(),t[i].l)-s.begin()+1;
t[i].r=lower_bound(s.begin(),s.end(),t[i].r)-s.begin()+1;
// cout<<t[i].l<<" "<<t[i].r<<endl;
}
sort(t+1,t+1+n,[&](seg a,seg b){
if(a.l!=b.l)return a.l<b.l;
else return a.r>b.r;
});
for(int i=1;i<=n;i++){
res[i]=query(t[i].r);
modify(t[i].r,res[i]+1);
}
for(int i=1;i<=n;i++){
printf("%d ",res[i]);
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 5868kb
input:
4 2 8 1 7 4 5 5 2
output:
0 0 1 2
result:
ok single line: '0 0 1 2 '
Test #2:
score: 0
Accepted
time: 1ms
memory: 5884kb
input:
5 2 4 3 3 2 2 4 2 4 1
output:
0 1 1 2 3
result:
ok single line: '0 1 1 2 3 '
Test #3:
score: -100
Wrong Answer
time: 122ms
memory: 8808kb
input:
200000 75760147 173015388 62879760 211229046 6728658 106668560 29476341 129401393 30531505 130450085 39792769 139780734 59486082 221617335 12447225 112582555 94207716 117434450 68962063 193352291 13519090 113644734 60611935 218232526 77901558 166662816 40316254 140281744 39094390 138994435 49921965 ...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
wrong answer 1st lines differ - expected: '51062 25770 5 10 10 12 19010 7...59 9 12 84254 91909 88054 9 7 7', found: '0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ... 99902 99903 99904 99905 99906 '