QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#501408 | #5159. Justice Served | cloudsss | TL | 2ms | 12088kb | C++20 | 1.1kb | 2024-08-02 17:56:35 | 2024-08-02 17:56:36 |
Judging History
answer
#include<bits/stdc++.h>
#define INF 200010
#define mod 80112002
#define pi 3.14159265359
using namespace std;
typedef long long LL;
int n,m;
string s[INF];
struct peo
{
int l,r;
bool operator<(const peo& ano)
{
if(l==ano.l)
return r>ano.r;
return l<ano.l;
}
} a[INF];
int ans[INF]= {0};
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n;
cin>>n;
for(int i=1; i<=n; i++)
{
int x,y;
cin>>x>>y;
a[i].l=x;
a[i].r=x+y;
}
sort(a+1,a+1+n);
int ansn=0;
for(int i=1;i<=n;i++)
{
for(int j=1;j<i;j++)
{
if(a[i].l>=a[j].l&&a[i].r<=a[j].r&&ans[j]!=0)
{
ansn=max(ansn,ans[j]+1);
}
else if(a[i].l>=a[j].l&&a[i].r<=a[j].r&&ans[j]==0)
{
ans[i]=1;
ansn=1;
}
}
ans[i]=ansn;
}
for(int i=1;i<=n;i++)
cout<<ans[i]<<" ";
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 11376kb
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: 2ms
memory: 12088kb
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
Time Limit Exceeded
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 ...