unsigned X=12345;int rand_(){return(X*=3)/2;}
int(*compar)(int,int);
void sort(int*aa,int l,int r)
{
while(l<r)
{
int i=l,j=l,k=r,t,p=aa[l+rand_()%(r-l)];
while(j<k)
switch(compar(aa[j],p))
{
case 0:++j;break;
case -1:t=aa[j],aa[j]=aa[i],aa[i]=t,++i,++j;break;
case 1:t=aa[--k],aa[k]=aa[j],aa[j]=t;break;
}
sort(aa,l,i);
l=k;
}
}
#include<stdio.h>
#define N 200005
int n,x[N],y[N],o[N],z,far;
int c(int i,int j)
{
if(x[i]==x[j])return y[i]>y[j]?-1:y[i]<y[j]?1:0;
return x[i]<x[j]?-1:x[i]>x[j]?1:0;
}
int main()
{
scanf("%d",&n);
for(int i=0;i<n;++i)
{
scanf("%d%d",x+i,y+i),o[i]=i;
int t=x[i];
x[i]=t-y[i];
y[i]=t+y[i];
}
compar=c;
sort(o,0,n);
for(int i=0;i<n;++i)
{
if(far>=y[o[i]])
;
else
far=y[o[i]],++z;
}
printf("%d",z);
}
Compilation message
lightningrod.c: In function 'main':
lightningrod.c:34:5: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
34 | scanf("%d",&n);
| ^~~~~~~~~~~~~~
lightningrod.c:37:9: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
37 | scanf("%d%d",x+i,y+i),o[i]=i;
| ^~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
26 ms |
7504 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Incorrect |
0 ms |
428 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Incorrect |
0 ms |
428 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Incorrect |
0 ms |
428 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Incorrect |
0 ms |
428 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
46 ms |
4644 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
26 ms |
7504 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |