Submission #1498442
Source Code Expand
def airport_bus(): n, c, k = map(int, raw_input().split(" ")) t = [] for i in range(n): t.append(int(raw_input())) t.sort() dic_busno_sate = {} current_bus = 1 for x in t: c_state = dic_busno_sate.get(current_bus) if c_state is None: dic_busno_sate[current_bus] = ([x, x+k], 1) else: time_range = c_state[0] p_num = c_state[1] if p_num>=c: current_bus+=1 dic_busno_sate[current_bus] = ([x, x + k], 1) else: left_max = max(time_range[0], x) right_min = min(time_range[1], x+k) if left_max<=right_min: _p_num = p_num+1 _time_range = [left_max, right_min] dic_busno_sate[current_bus] = (_time_range, _p_num) else: current_bus += 1 dic_busno_sate[current_bus] = ([x, x + k], 1) print current_bus if __name__ == "__main__": airport_bus()
Submission Info
Submission Time | |
---|---|
Task | A - Airport Bus |
User | zhuang |
Language | Python (2.7.6) |
Score | 300 |
Code Size | 845 Byte |
Status | AC |
Exec Time | 277 ms |
Memory | 34416 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 | 13 ms | 2696 KB |
in2.txt | AC | 211 ms | 10224 KB |
in3.txt | AC | 277 ms | 34288 KB |
in4.txt | AC | 257 ms | 34416 KB |
in5.txt | AC | 15 ms | 2816 KB |
in6.txt | AC | 227 ms | 16880 KB |
in7.txt | AC | 202 ms | 9812 KB |
in8.txt | AC | 220 ms | 10480 KB |
sample1.txt | AC | 11 ms | 2696 KB |
sample2.txt | AC | 11 ms | 2696 KB |