Submission #2509181
Source Code Expand
def d_precipitation(N, TIME): import itertools # 時刻を5分刻みにする time = [] for rain in TIME: # rain:'降り始め時刻(hh時mm分)-降り終わり時刻(hh時mm分)' # start/end : 開始/終了 時刻(0時0分からの経過時間(分)) start = int(rain[0:2]) * 60 + int(rain[2:4]) end = int(rain[5:7]) * 60 + int(rain[7:9]) start -= start % 5 # 直前の5分単位に丸める end += (5 - (end % 5)) % 5 # 直後の5分単位に丸める time.append((start, end)) time.sort() # 開始時刻の早いものソート time_part = [0] * 1442 # 1440分(1日)に分ける.0分のため+1,番兵に+1 for start, end in time: time_part[start] += 1 time_part[end + 1] -= 1 time_part = itertools.accumulate(time_part) # 累積和を取る # 開始終了時刻を復元 tmp = [] is_zero = True # Trueなら0が,Falseなら1以上の値が現れた start, end = 0, 0 for i, t in enumerate(time_part): if t > 0 and is_zero: # 0でない値が現れたので開始時刻とする start = i is_zero = False if t == 0 and not is_zero: # 0が現れたので終了時刻とする end = i - 1 is_zero = True tmp.append('{0:02d}{1:02d}-{2:02d}{3:02d}'.format( start // 60, start % 60, end // 60, end % 60)) ans = '\n'.join(tmp) return ans N = int(input()) TIME = [input() for i in range(N)] print(d_precipitation(N, TIME))
Submission Info
Submission Time | |
---|---|
Task | D - 感雨時刻の整理 |
User | kenseiQ |
Language | Python (3.4.3) |
Score | 100 |
Code Size | 1590 Byte |
Status | AC |
Exec Time | 141 ms |
Memory | 9432 KB |
Judge Result
Set Name | all | ||
---|---|---|---|
Score / Max Score | 100 / 100 | ||
Status |
|
Set Name | Test Cases |
---|---|
all | 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, cho_cho_chokudai.txt, chokudai_ga_cho.txt, test_01.txt, test_02.txt, test_03.txt, test_04.txt, test_05.txt, test_06.txt, test_07.txt, test_08.txt, test_09.txt, test_10.txt, test_11.txt, test_12.txt, test_13.txt, test_14.txt, test_15.txt, test_16.txt, test_17.txt, test_18.txt, test_19.txt, test_20.txt, test_21.txt, test_22.txt, test_23.txt, test_24.txt, test_25.txt, test_26.txt, test_27.txt, test_28.txt, test_29.txt, test_30.txt, test_31.txt, test_32.txt, test_33.txt, test_34.txt, test_35.txt, test_36.txt, test_37.txt, test_38.txt, test_39.txt, test_40.txt, test_41.txt, test_42.txt, test_43.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00_sample_01.txt | AC | 18 ms | 3064 KB |
00_sample_02.txt | AC | 18 ms | 3064 KB |
00_sample_03.txt | AC | 18 ms | 3064 KB |
cho_cho_chokudai.txt | AC | 104 ms | 8456 KB |
chokudai_ga_cho.txt | AC | 115 ms | 9028 KB |
test_01.txt | AC | 18 ms | 3064 KB |
test_02.txt | AC | 18 ms | 3064 KB |
test_03.txt | AC | 18 ms | 3064 KB |
test_04.txt | AC | 19 ms | 3064 KB |
test_05.txt | AC | 19 ms | 3064 KB |
test_06.txt | AC | 18 ms | 3064 KB |
test_07.txt | AC | 18 ms | 3064 KB |
test_08.txt | AC | 18 ms | 3064 KB |
test_09.txt | AC | 20 ms | 3188 KB |
test_10.txt | AC | 20 ms | 3188 KB |
test_11.txt | AC | 19 ms | 3064 KB |
test_12.txt | AC | 19 ms | 3064 KB |
test_13.txt | AC | 18 ms | 3064 KB |
test_14.txt | AC | 19 ms | 3188 KB |
test_15.txt | AC | 20 ms | 3188 KB |
test_16.txt | AC | 18 ms | 3064 KB |
test_17.txt | AC | 19 ms | 3188 KB |
test_18.txt | AC | 18 ms | 3064 KB |
test_19.txt | AC | 19 ms | 3064 KB |
test_20.txt | AC | 19 ms | 3064 KB |
test_21.txt | AC | 129 ms | 9220 KB |
test_22.txt | AC | 141 ms | 9372 KB |
test_23.txt | AC | 128 ms | 9268 KB |
test_24.txt | AC | 128 ms | 9372 KB |
test_25.txt | AC | 133 ms | 9256 KB |
test_26.txt | AC | 126 ms | 9072 KB |
test_27.txt | AC | 118 ms | 9432 KB |
test_28.txt | AC | 125 ms | 9144 KB |
test_29.txt | AC | 18 ms | 3064 KB |
test_30.txt | AC | 18 ms | 3064 KB |
test_31.txt | AC | 34 ms | 3956 KB |
test_32.txt | AC | 18 ms | 3064 KB |
test_33.txt | AC | 89 ms | 6932 KB |
test_34.txt | AC | 18 ms | 3064 KB |
test_35.txt | AC | 19 ms | 3064 KB |
test_36.txt | AC | 131 ms | 9364 KB |
test_37.txt | AC | 125 ms | 9016 KB |
test_38.txt | AC | 128 ms | 9000 KB |
test_39.txt | AC | 129 ms | 9432 KB |
test_40.txt | AC | 124 ms | 8748 KB |
test_41.txt | AC | 117 ms | 9028 KB |
test_42.txt | AC | 123 ms | 9024 KB |
test_43.txt | AC | 111 ms | 9020 KB |