Submission #1370291


Source Code Expand

#include <bits/stdc++.h>
using namespace std;

const int N = 1e5 + 10;

int n, k, c, ans, cnt, a[N];

int main(){
	cin >> n >> c >> k;
	for(int i = 1; i <= n; ++ i){
		cin >> a[i];
	}
	sort(a + 1, a + n + 1);
	int bg = -1;
	for(int i = 1; i <= n; ++ i){
		if(bg != -1 && (a[i] - bg > k || cnt == c)){
			bg = -1;
			cnt = 0;
		} 
		if(bg == -1) {
			bg = a[i];
			ans ++;
		}
		if(a[i] - bg <= k && cnt < c){
			cnt ++;
		}
	}
	cout << ans;
	return 0;
}

Submission Info

Submission Time
Task A - Airport Bus
User KtlTheBest
Language C++14 (GCC 5.4.1)
Score 300
Code Size 482 Byte
Status AC
Exec Time 60 ms
Memory 640 KB

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 256 KB
in2.txt AC 59 ms 640 KB
in3.txt AC 60 ms 640 KB
in4.txt AC 59 ms 640 KB
in5.txt AC 2 ms 256 KB
in6.txt AC 60 ms 640 KB
in7.txt AC 52 ms 640 KB
in8.txt AC 60 ms 640 KB
sample1.txt AC 1 ms 256 KB
sample2.txt AC 1 ms 256 KB