Submission #1156532
Source Code Expand
#include <cstdio>
#include <algorithm>
using namespace std;
int N;
int C, K;
int T[100010];
void solve()
{
sort(T, T+N);
int res = 1;
int i, j;
i = 0;
j = 0;
while(1){
if(T[j]-T[i] <= K && j-i+1<=C){
j ++;
if(j == N)
break;
}
else{
res ++;
i = j;
}
}
printf("%d\n", res);
}
int main()
{
int i;
scanf("%d", &N);
scanf("%d%d", &C, &K);
for(i=0; i<N; i++)
scanf("%d", &T[i]);
solve();
return 0;
}
Submission Info
Submission Time |
|
Task |
A - Airport Bus |
User |
treeofapple |
Language |
C++14 (GCC 5.4.1) |
Score |
300 |
Code Size |
474 Byte |
Status |
AC |
Exec Time |
18 ms |
Memory |
512 KB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:33:17: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &N);
^
./Main.cpp:34:23: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d", &C, &K);
^
./Main.cpp:36:21: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &T[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 |
18 ms |
512 KB |
in3.txt |
AC |
18 ms |
512 KB |
in4.txt |
AC |
18 ms |
512 KB |
in5.txt |
AC |
1 ms |
128 KB |
in6.txt |
AC |
18 ms |
512 KB |
in7.txt |
AC |
16 ms |
512 KB |
in8.txt |
AC |
18 ms |
512 KB |
sample1.txt |
AC |
1 ms |
128 KB |
sample2.txt |
AC |
1 ms |
128 KB |