Submission #520555
Source Code Expand
require "time" class Range def overlap?(other) !self.no_overlap?(other) end def no_overlap?(other) self.last < other.first || self.first > other.last end def widen(other) raise "#widen should be called with overlapping ranges" if self.no_overlap?(other) ([self.first, other.first].min)..([self.last, other.last].max) end end class Time def floor(sec) self - (self.to_i % sec) end def ceil(sec) return self if (self.to_i % sec).zero? self + sec - (self.to_i % sec) end end def lines2ranges(lines) lines.map{|time_range| time_range.split("-"). map{|time_s| Time.strptime(time_s, "%H%M") } }. map{|(began, ended)| began.floor(300)..ended.ceil(300) }. sort_by(&:first) end def shrink_ranges(ranges) [].tap do |outs| ranges.each do |range| next if outs.empty? && outs << range next if outs.last.no_overlap?(range) && outs << range outs[-1] = outs.last.widen(range) end end end def fix_overdates(range_s) return range_s unless range_s.all?{|s| s == "0000"} ["0000", "2400"] end def formatize(ranges) ranges.each do |range| range_s = [:first, :last]. map{|method| range.send(method) }. map{|time| time.strftime("%H%M") } puts "#{fix_overdates(range_s).join("-")}" end end def main inputs = STDIN.readlines.map(&:chomp).delete_if(&:empty?) inputs.shift # remove first element formatize( shrink_ranges( lines2ranges(inputs) ) ) end main
Submission Info
Submission Time | |
---|---|
Task | D - 感雨時刻の整理 |
User | zeroyonichihachi |
Language | Ruby (1.9.3) |
Score | 0 |
Code Size | 1576 Byte |
Status | TLE |
Exec Time | 2085 ms |
Memory | 26068 KB |
Judge Result
Set Name | all | ||||||
---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 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 | 63 ms | 3708 KB |
00_sample_02.txt | AC | 52 ms | 3588 KB |
00_sample_03.txt | AC | 53 ms | 3588 KB |
cho_cho_chokudai.txt | TLE | 2073 ms | 25300 KB |
chokudai_ga_cho.txt | TLE | 2077 ms | 25036 KB |
test_01.txt | AC | 67 ms | 3708 KB |
test_02.txt | AC | 64 ms | 3708 KB |
test_03.txt | AC | 66 ms | 3712 KB |
test_04.txt | AC | 63 ms | 3776 KB |
test_05.txt | AC | 65 ms | 3584 KB |
test_06.txt | AC | 71 ms | 3708 KB |
test_07.txt | AC | 65 ms | 3712 KB |
test_08.txt | AC | 62 ms | 3588 KB |
test_09.txt | AC | 99 ms | 3968 KB |
test_10.txt | AC | 102 ms | 3964 KB |
test_11.txt | AC | 91 ms | 3964 KB |
test_12.txt | AC | 85 ms | 3588 KB |
test_13.txt | AC | 68 ms | 3712 KB |
test_14.txt | AC | 95 ms | 3924 KB |
test_15.txt | AC | 105 ms | 3964 KB |
test_16.txt | WA | 66 ms | 3584 KB |
test_17.txt | WA | 94 ms | 3968 KB |
test_18.txt | WA | 68 ms | 3584 KB |
test_19.txt | WA | 83 ms | 3712 KB |
test_20.txt | WA | 88 ms | 3840 KB |
test_21.txt | TLE | 2076 ms | 25068 KB |
test_22.txt | TLE | 2085 ms | 24660 KB |
test_23.txt | TLE | 2072 ms | 24916 KB |
test_24.txt | TLE | 2073 ms | 25296 KB |
test_25.txt | TLE | 2073 ms | 25556 KB |
test_26.txt | TLE | 2072 ms | 26068 KB |
test_27.txt | TLE | 2072 ms | 24788 KB |
test_28.txt | TLE | 2071 ms | 25432 KB |
test_29.txt | AC | 57 ms | 3588 KB |
test_30.txt | AC | 55 ms | 3712 KB |
test_31.txt | WA | 393 ms | 7416 KB |
test_32.txt | AC | 57 ms | 3708 KB |
test_33.txt | WA | 1577 ms | 24596 KB |
test_34.txt | AC | 53 ms | 3584 KB |
test_35.txt | AC | 72 ms | 3708 KB |
test_36.txt | TLE | 2072 ms | 25344 KB |
test_37.txt | TLE | 2076 ms | 24148 KB |
test_38.txt | TLE | 2080 ms | 24624 KB |
test_39.txt | TLE | 2073 ms | 24632 KB |
test_40.txt | TLE | 2075 ms | 22996 KB |
test_41.txt | TLE | 2072 ms | 24536 KB |
test_42.txt | TLE | 2071 ms | 24788 KB |
test_43.txt | TLE | 2074 ms | 23764 KB |