Submission #2178985
Source Code Expand
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int cmp(const void *a,const void *b)
{
return *(int *)a-*(int *)b;
}
int main ()
{
int a[100001],b[100001],n,m,k,t,i,j,c,d,e=0,f;
scanf ("%d%d%d",&n,&m,&k);
if (m==1) printf ("%d",n);
else {
for (i=0;i<n;i++)
scanf ("%d",&a[i]);
qsort(a,n,sizeof a[0],cmp);
for (i=0;i<n;i++)
{
for (c=i,d=i+1;d-c<m&&a[d]-a[c]<=k&&d<n;d++)
{
}
e++;
i=d-1;
}
printf ("%d",e);
}
return 0;
}
Submission Info
Submission Time |
|
Task |
A - Airport Bus |
User |
vjudge5 |
Language |
C++14 (GCC 5.4.1) |
Score |
300 |
Code Size |
458 Byte |
Status |
AC |
Exec Time |
24 ms |
Memory |
892 KB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:11:28: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf ("%d%d%d",&n,&m,&k);
^
./Main.cpp:16:20: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf ("%d",&a[i]);
^
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
300 / 300 |
Status |
|
|
Set Name |
Test Cases |
Sample |
sample1.txt, sample2.txt |
All |
sample1.txt, sample2.txt, in1.txt, in2.txt, in3.txt, in4.txt, in5.txt, in6.txt, in7.txt, in8.txt, sample1.txt, sample2.txt |
Case Name |
Status |
Exec Time |
Memory |
in1.txt |
AC |
1 ms |
128 KB |
in2.txt |
AC |
24 ms |
892 KB |
in3.txt |
AC |
24 ms |
892 KB |
in4.txt |
AC |
1 ms |
128 KB |
in5.txt |
AC |
1 ms |
252 KB |
in6.txt |
AC |
24 ms |
892 KB |
in7.txt |
AC |
21 ms |
892 KB |
in8.txt |
AC |
24 ms |
892 KB |
sample1.txt |
AC |
1 ms |
128 KB |
sample2.txt |
AC |
1 ms |
128 KB |