Submission #1372554


Source Code Expand

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define swap(type,a,b) do{type t=a;a=b;b=t;}while(0);
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ll long long
#define INF 100000000
#define FOR(i,a,n) for(i=a;i<n;i++)
int comp(const void* a,const void* b){
	return *(int*)a-*(int*)b;
}
void fill(int a[],int b,int c){
	int i;
	FOR(i,0,b) a[i]=c;
	return;
}
int a[100000];
int main(void)
{
	int n,c,k,cnt,res=0,t,i;
	scanf("%d%d%d",&n,&c,&k);
	FOR(i,0,n) scanf("%d",&a[i]);
	qsort(a,n,sizeof(int),comp);
	for(i=0;;){
		t=a[i]+k;
		cnt=0,res++;
		while(i<n&&cnt<c&&a[i]<=t) i++,cnt++;
		if(i==n) break;
	}
	printf("%d\n",res);
	return 0;
}
    

Submission Info

Submission Time
Task A - Airport Bus
User trainstation
Language C (GCC 5.4.1)
Score 300
Code Size 744 Byte
Status AC
Exec Time 25 ms
Memory 892 KB

Compile Error

./Main.c: In function ‘main’:
./Main.c:23:2: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d%d",&n,&c,&k);
  ^
./Main.c:24:13: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
  FOR(i,0,n) scanf("%d",&a[i]);
             ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 2
AC × 12
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 25 ms 892 KB
in3.txt AC 25 ms 892 KB
in4.txt AC 25 ms 892 KB
in5.txt AC 1 ms 128 KB
in6.txt AC 25 ms 892 KB
in7.txt AC 22 ms 892 KB
in8.txt AC 25 ms 892 KB
sample1.txt AC 1 ms 128 KB
sample2.txt AC 1 ms 128 KB