Submission #4066912
Source Code Expand
using System; using System.Collections.Generic; using System.Linq; class Scanner //標準入力 { string[] s; int i; char[] cs = new char[] { ' ' }; public Scanner() { s = new string[0]; i = 0; } public string next() { if (i < s.Length) return s[i++]; string st = Console.ReadLine(); while (st == "") st = Console.ReadLine(); s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries); if (s.Length == 0) return next(); i = 0; return s[i++]; } public int Int() { return int.Parse(next()); } public int[] ArrayInt(int N, int add = 0) { int[] Array = new int[N]; for (int i = 0; i < N; i++) { Array[i] = Int() + add; } return Array; } public long Long() { return long.Parse(next()); } public long[] ArrayLong(int N, long add = 0) { long[] Array = new long[N]; for (int i = 0; i < N; i++) { Array[i] = Long() + add; } return Array; } } class Program { static Scanner cin = new Scanner(); static void Main(string[] args) { int N = cin.Int(); int C = cin.Int(); int K = cin.Int(); var T = new int[N]; for (int i = 0; i < N; i++) { T[i] = cin.Int(); } Array.Sort(T); int first = 0, cnt = 0; while (true) { if (first >= N) break; else if (first + C - 1 >= N) { if (T[N - 1] <= T[first] + K) { //残り全員乗れる cnt++; first = N; break; } else { int index = first; while (T[index] <= T[first] + K) index++; first = index; cnt++; } } else { if (T[first + C - 1] <= T[first] + K) { //C人ちょうど乗れるとき cnt++; first += C; } else { //来るのが遅くて最初の人からK経った人までを乗せるとき int index = first; while (T[index] <= T[first] + K) index++; first = index; cnt++; } } } Console.WriteLine(cnt); Console.ReadLine(); } }
Submission Info
Submission Time | |
---|---|
Task | A - Airport Bus |
User | Mikoshi |
Language | C# (Mono 4.6.2.0) |
Score | 300 |
Code Size | 2555 Byte |
Status | AC |
Exec Time | 97 ms |
Memory | 15444 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 | 23 ms | 11220 KB |
in2.txt | AC | 93 ms | 15444 KB |
in3.txt | AC | 93 ms | 15444 KB |
in4.txt | AC | 93 ms | 13396 KB |
in5.txt | AC | 22 ms | 9156 KB |
in6.txt | AC | 97 ms | 15444 KB |
in7.txt | AC | 86 ms | 15336 KB |
in8.txt | AC | 94 ms | 13396 KB |
sample1.txt | AC | 21 ms | 9172 KB |
sample2.txt | AC | 21 ms | 11220 KB |