Submission #1369639
Source Code Expand
import java.util.*; class Main { public static void main(String args[]) { int n,c,k; Scanner sc=new Scanner(System.in); n=sc.nextInt(); c=sc.nextInt(); k=sc.nextInt(); int[] t=new int[n]; for(int i=0;i<n;i++) t[i]=sc.nextInt(); Arrays.sort(t); int i=0,start,bus=1,people=0; start=t[0]; while(i<n) { if(t[i]-start>k) { bus++; people=0; start=t[i]; } people++; if(people==c) { bus++; people=0; if(i+1<n) start=t[i+1]; else bus--; } i++; } System.out.print(bus); } }
Submission Info
Submission Time | |
---|---|
Task | A - Airport Bus |
User | jeelvashnav1999 |
Language | Java8 (OpenJDK 1.8.0) |
Score | 300 |
Code Size | 762 Byte |
Status | AC |
Exec Time | 511 ms |
Memory | 50352 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 300 / 300 | ||||
Status |
|
|
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 | 133 ms | 20180 KB |
in2.txt | AC | 487 ms | 48456 KB |
in3.txt | AC | 479 ms | 47420 KB |
in4.txt | AC | 473 ms | 45836 KB |
in5.txt | AC | 139 ms | 24912 KB |
in6.txt | AC | 511 ms | 50352 KB |
in7.txt | AC | 464 ms | 48608 KB |
in8.txt | AC | 475 ms | 47628 KB |
sample1.txt | AC | 93 ms | 19668 KB |
sample2.txt | AC | 94 ms | 19796 KB |