Submission #2178341
Source Code Expand
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
typedef long long ll;
int cmp(const void *a, const void *b)
{
return *(ll *)a-*(ll *)b;
}
int main()
{
ll N,C,K,T[100005];
ll p_num,i,j,bus_num;
scanf("%lld %lld %lld",&N,&C,&K);
for (i=0;i<N;i++) {
scanf("%lld",&T[i]);
}
qsort(T,N,sizeof(T[0]),cmp);
j=T[0];p_num=0;bus_num=1;
for (i=0;i<N;i++) {
if (T[i]<=j+K) p_num++;
else {
bus_num++;j=T[i+1];p_num=1;
}
if (p_num>=C) {
p_num=0;
bus_num++;
j=T[i+1];
}
}
printf("%lld\n",bus_num);
return 0;
}
Submission Info
Submission Time |
|
Task |
A - Airport Bus |
User |
vjudge5 |
Language |
C++14 (GCC 5.4.1) |
Score |
0 |
Code Size |
537 Byte |
Status |
WA |
Exec Time |
25 ms |
Memory |
1788 KB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:13:34: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%lld %lld %lld",&N,&C,&K);
^
./Main.cpp:15:22: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%lld",&T[i]);
^
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
0 / 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 |
252 KB |
in2.txt |
AC |
24 ms |
1788 KB |
in3.txt |
WA |
24 ms |
1788 KB |
in4.txt |
WA |
24 ms |
1788 KB |
in5.txt |
AC |
1 ms |
252 KB |
in6.txt |
WA |
25 ms |
1788 KB |
in7.txt |
WA |
21 ms |
1532 KB |
in8.txt |
WA |
24 ms |
1788 KB |
sample1.txt |
AC |
0 ms |
128 KB |
sample2.txt |
AC |
0 ms |
128 KB |