Submission #1156875


Source Code Expand

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<map>
using namespace std;
const int MaxN = 1e5 + 5;
int box[MaxN];
int cnt, c, n, k;
int main(){
	while(~scanf("%d %d %d", &n, &c, &k)){
		for(int i = 1; i <= n; i++)
			scanf("%d", &box[i]);
		sort(box + 1, box + 1 + n);
		int l, r;
		l = r = 1;
		cnt = 0;
		while(l <= n){
			int temp = box[l] + k;
			while(box[r + 1] <= temp && r - l < c - 1 && r < n)
				r++;
			cnt++;
			l = r + 1;
		}
		printf("%d\n", cnt);
	}
	return 0;
}

Submission Info

Submission Time
Task A - Airport Bus
User ZZZZone
Language C++14 (GCC 5.4.1)
Score 300
Code Size 559 Byte
Status AC
Exec Time 18 ms
Memory 512 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:14:24: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d", &box[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 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 0 ms 128 KB
sample2.txt AC 1 ms 128 KB