Submission #2276308
Source Code Expand
def d_precipitation(N, TIME): # 時刻を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日=1440分)の区間に分ける."0"を入れるため+1,番兵として+1 for start, end in time: time_part[start] += 1 time_part[end + 1] -= 1 for i in range(len(time_part) - 1): time_part[i + 1] += time_part[i] # 1以上の要素が出てきた区間をs,eに詰める(s[i],e[i]が開始-終了時刻の組) s, e = [], [] is_zero = True # Trueなら0が,Falseなら1以上の値が現れた for i, t in enumerate(time_part): if t > 0 and is_zero: s.append(i) is_zero = False if t == 0 and not is_zero: e.append(i - 1) is_zero = True # 開始終了時刻を復元 ans = '' for start, end in zip(s, e): ans += '{0:02d}{1:02d}-{2:02d}{3:02d}\n'.format( start // 60, start % 60, end // 60, end % 60) return ans[:-1] 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 | 1642 Byte |
Status | AC |
Exec Time | 139 ms |
Memory | 9328 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 | 103 ms | 8400 KB |
chokudai_ga_cho.txt | AC | 116 ms | 8980 KB |
test_01.txt | AC | 18 ms | 3064 KB |
test_02.txt | AC | 18 ms | 3064 KB |
test_03.txt | AC | 19 ms | 3064 KB |
test_04.txt | AC | 18 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 | 20 ms | 3064 KB |
test_12.txt | AC | 19 ms | 3064 KB |
test_13.txt | AC | 18 ms | 3064 KB |
test_14.txt | AC | 20 ms | 3064 KB |
test_15.txt | AC | 20 ms | 3188 KB |
test_16.txt | AC | 18 ms | 3064 KB |
test_17.txt | AC | 19 ms | 3064 KB |
test_18.txt | AC | 19 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 | 9060 KB |
test_22.txt | AC | 139 ms | 9328 KB |
test_23.txt | AC | 133 ms | 9152 KB |
test_24.txt | AC | 131 ms | 9320 KB |
test_25.txt | AC | 131 ms | 9208 KB |
test_26.txt | AC | 124 ms | 8948 KB |
test_27.txt | AC | 114 ms | 9244 KB |
test_28.txt | AC | 123 ms | 9108 KB |
test_29.txt | AC | 18 ms | 3064 KB |
test_30.txt | AC | 18 ms | 3064 KB |
test_31.txt | AC | 34 ms | 3824 KB |
test_32.txt | AC | 18 ms | 3064 KB |
test_33.txt | AC | 87 ms | 6884 KB |
test_34.txt | AC | 18 ms | 3064 KB |
test_35.txt | AC | 19 ms | 3064 KB |
test_36.txt | AC | 128 ms | 9328 KB |
test_37.txt | AC | 124 ms | 8948 KB |
test_38.txt | AC | 124 ms | 8956 KB |
test_39.txt | AC | 128 ms | 9260 KB |
test_40.txt | AC | 122 ms | 8692 KB |
test_41.txt | AC | 114 ms | 8964 KB |
test_42.txt | AC | 125 ms | 8952 KB |
test_43.txt | AC | 107 ms | 8984 KB |