Submission #1156429


Source Code Expand

import java.io.*;
import java.util.*;

public class Main
{
	public static void main(String[] args) throws IOException
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
		StringTokenizer st = new StringTokenizer(br.readLine());
		int n = Integer.parseInt(st.nextToken()), c = Integer.parseInt(st.nextToken()), k = Integer.parseInt(st.nextToken());
		int[] times = new int[n];
		for(int i = 0; i < n; i++)
			times[i] = Integer.parseInt(br.readLine());
		Arrays.sort(times);
		int i = 0, buses = 0;
		while(i < n)
		{
			int end = times[i] + k, num = 1;
			i++;
			while(i < n && times[i] <= end && num < c)
			{
				num++;
				i++;
			}
			buses++;
		}
		pw.println(buses);
		br.close();
		pw.close();
		System.exit(0);
	}
}

Submission Info

Submission Time
Task A - Airport Bus
User arnavbansal
Language Java8 (OpenJDK 1.8.0)
Score 300
Code Size 876 Byte
Status AC
Exec Time 217 ms
Memory 30892 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 146 ms 20948 KB
in2.txt AC 172 ms 30892 KB
in3.txt AC 176 ms 27972 KB
in4.txt AC 174 ms 27908 KB
in5.txt AC 76 ms 19796 KB
in6.txt AC 217 ms 27656 KB
in7.txt AC 164 ms 26624 KB
in8.txt AC 169 ms 30828 KB
sample1.txt AC 67 ms 21076 KB
sample2.txt AC 68 ms 20564 KB