Submission #1970899


Source Code Expand

Copy
lines = $stdin.read
array = lines.split("\n")

N = array[0].to_i
vec = Array.new(24*60+1){0}

def round_st(n)
  if n % 5 == 0
    n
  else
    5 * (n/5)
  end
end

def round_ed(n)
  if n % 5 == 0
    n
  else
    5 * (n/5) + 5
  end
end

array[1..N].each do |s|
  start,finish = s.split("-")
  # puts "start  = #{start[0,2].to_i*60  + start[2,2].to_i}"
  # puts "finish = #{finish[0,2].to_i*60 + finish[2,2].to_i}"
  s = start[0,2].to_i*60  + round_st(start[2,2].to_i)
  f = finish[0,2].to_i*60 + round_ed(finish[2,2].to_i)
  vec[s] = vec[s] + 1
  vec[f] = vec[f] - 1
end

for i in 1...vec.length
  vec[i] += vec[i-1]
end

is_rainny = false

vec.each_with_index do |v,i|
  if v == 0
    # not rain
    if is_rainny
      is_rainny = false
      printf "-%02d%02d\n", i/60,i%60
    end
  else
    # rain
    if not is_rainny
      is_rainny = true
      printf "%02d%02d", i/60,i%60
    end
  end
end

Submission Info

Submission Time
Task D - 感雨時刻の整理
User hiroyuking
Language Ruby (2.3.3)
Score 100
Code Size 951 Byte
Status
Exec Time 69 ms
Memory 4220 KB

Compile Error

./Main.rb:39: warning: shadowing outer local variable - i

Test Cases

Set Name Score / Max Score Test Cases
all 100 / 100 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 7 ms 1788 KB
00_sample_02.txt 7 ms 1788 KB
00_sample_03.txt 7 ms 1788 KB
cho_cho_chokudai.txt 66 ms 4220 KB
chokudai_ga_cho.txt 65 ms 4220 KB
test_01.txt 8 ms 1788 KB
test_02.txt 8 ms 1788 KB
test_03.txt 8 ms 1788 KB
test_04.txt 8 ms 1788 KB
test_05.txt 8 ms 1788 KB
test_06.txt 8 ms 1788 KB
test_07.txt 8 ms 1788 KB
test_08.txt 8 ms 1788 KB
test_09.txt 9 ms 1788 KB
test_10.txt 9 ms 1788 KB
test_11.txt 9 ms 1788 KB
test_12.txt 9 ms 1788 KB
test_13.txt 8 ms 1788 KB
test_14.txt 9 ms 1788 KB
test_15.txt 9 ms 1788 KB
test_16.txt 8 ms 1788 KB
test_17.txt 9 ms 1788 KB
test_18.txt 8 ms 1788 KB
test_19.txt 9 ms 1788 KB
test_20.txt 9 ms 1788 KB
test_21.txt 67 ms 4220 KB
test_22.txt 67 ms 4220 KB
test_23.txt 66 ms 4220 KB
test_24.txt 66 ms 4220 KB
test_25.txt 67 ms 4220 KB
test_26.txt 69 ms 4220 KB
test_27.txt 67 ms 4220 KB
test_28.txt 66 ms 4220 KB
test_29.txt 8 ms 1788 KB
test_30.txt 8 ms 1788 KB
test_31.txt 18 ms 2172 KB
test_32.txt 8 ms 1788 KB
test_33.txt 48 ms 3836 KB
test_34.txt 8 ms 1788 KB
test_35.txt 8 ms 1788 KB
test_36.txt 68 ms 4220 KB
test_37.txt 66 ms 4220 KB
test_38.txt 65 ms 4220 KB
test_39.txt 67 ms 4220 KB
test_40.txt 67 ms 4220 KB
test_41.txt 64 ms 4220 KB
test_42.txt 64 ms 4220 KB
test_43.txt 64 ms 4220 KB