QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#201506#5159. Justice ServedBoulevardDust#WA 27ms10676kbC++20737b2023-10-05 14:47:042023-10-05 14:47:04

Judging History

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

  • [2023-10-05 14:47:04]
  • 评测
  • 测评结果:WA
  • 用时:27ms
  • 内存:10676kb
  • [2023-10-05 14:47:04]
  • 提交

answer

#include<bits/stdc++.h>
#define N 300005
#define re 
using namespace std;
int n,m,K,q,T;
inline void Rd(int &res){
	re char c;res=0;
	while(c=getchar(),c<48);
	do res=(res<<3)+(res<<1)+(c^48);
	while(c=getchar(),c>47);
}
struct node{
	int l,r,id;
}a[N];
bool cmp(node a,node b){return (a.l<b.l)||(a.l==b.l&&a.r>b.r);}
node stk[N];
int top,ans[N];
int main(){
	Rd(n);
	for(re int i=1;i<=n;i++){
		Rd(a[i].l);a[i].id=i;
		int x;Rd(x);
		a[i].r=a[i].l+x;
	}
	sort(a+1,a+n+1,cmp);
	
	for(re int i=1;i<=n;i++){
		while(top&&(stk[top].l>a[i].l||stk[top].r<a[i].r))top--;
		stk[++top]=a[i];
		ans[a[i].id]=top-1;
	}
	for(re int i=1;i<=n;i++){
		printf("%d",ans[i]);
		putchar(i==n?'\n':' ');
	}
	return 0;
} 

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 5632kb

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: 5628kb

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: 27ms
memory: 10676kb

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:

10466 3593 3 4 4 4 5217 3 7152 9274 3 7360 9066 4 3 6 4 2697 4 4 4 10059 10426 7 4 9067 6 1 8286 7 2666 5 1 4678 6 7029 7147 2 1958 4498 3579 3 4063 8557 3166 3 3 5 1 8126 4406 5 2 4337 7696 8282 6 3 11127 11408 10212 4 7317 4 5 3 7 5 3 2628 4308 2 3 6 10774 2789 6390 1 8197 5334 9882 5330 2981 2397...

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: '10466 3593 3 4 4 4 5217 3 7152...6 2837 2 5 3105 5754 6905 3 5 3'