Submission #1497190


Source Code Expand

import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		new Main().solve();
	}
	
	void solve(){
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		int C=sc.nextInt();
		int K=sc.nextInt();
		int[]T=new int[N];
		for(int i=0;i<N;i++){
			T[i]=sc.nextInt();
		}
		Arrays.sort(T);
		
		int people=0;
		int limit=T[0]+K;
		int count=0;
		for(int i=0;i<N;i++){
			if(people==C){
				count++;
				people=0;
				limit=T[i]+K;
			}
			if(limit<T[i]){
				count++;
				people=0;
				limit=T[i]+K;
			}
			people++;
		}
		
		if(people>0){
			if(people%C==0)count+=people/C;
			else count+=people/C+1;
		}
		System.out.println(count);
		
	}
}

Submission Info

Submission Time
Task A - Airport Bus
User kwkm0429
Language Java8 (OpenJDK 1.8.0)
Score 300
Code Size 746 Byte
Status AC
Exec Time 495 ms
Memory 50120 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 125 ms 20180 KB
in2.txt AC 477 ms 46944 KB
in3.txt AC 493 ms 47484 KB
in4.txt AC 495 ms 47700 KB
in5.txt AC 139 ms 25428 KB
in6.txt AC 475 ms 50120 KB
in7.txt AC 458 ms 47648 KB
in8.txt AC 465 ms 46300 KB
sample1.txt AC 91 ms 21844 KB
sample2.txt AC 92 ms 19924 KB