Submission #856771


Source Code Expand

Copy
n = gets.to_i
xs = gets.split.map {|x| x.to_i}
xs << 10*12
l = gets.to_i
q = gets.to_i
as = []
bs = []


hsh = Hash.new
q.times { |_q|
  (astr,bstr) = gets.strip.split
  a = astr.to_i - 1
  b = bstr.to_i - 1
  as << a
  bs << b
  
  if (a>b)
    (b,a)=[a,b]
    (bstr,astr)=[astr,bstr]
  end

  #puts "#{a} #{b} #{l}"

  pos = a
  day = 0
  while pos <= b
    #puts "#{pos+1}"
    new_pos = pos
    while xs[new_pos+1] <= xs[pos] + l
      new_pos += 1
    end
    day += 1
    pos = new_pos
  end
  puts "#{day-1}"
  hsh[astr+":"+bstr] = day
}

Submission Info

Submission Time
Task E - Tak and Hotels
User cactoid
Language Ruby (2.3.3)
Score 0
Code Size 583 Byte
Status TLE
Exec Time 3160 ms
Memory 8844 KB

Compile Error

./Main.rb:1: warning: assigned but unused variable - n

Judge Result

Set Name Sample Subtask1 All
Score / Max Score 0 / 0 0 / 200 0 / 500
Status
AC × 1
AC × 1
TLE × 1
RE × 12
AC × 1
TLE × 8
RE × 18
Set Name Test Cases
Sample example_01.txt
Subtask1 example_01.txt, subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask1_13.txt
All example_01.txt, subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask1_13.txt, subtask2_01.txt, subtask2_02.txt, subtask2_03.txt, subtask2_04.txt, subtask2_05.txt, subtask2_06.txt, subtask2_07.txt, subtask2_08.txt, subtask2_09.txt, subtask2_10.txt, subtask2_11.txt, subtask2_12.txt, subtask2_13.txt
Case Name Status Exec Time Memory
example_01.txt AC 17 ms 1788 KB
subtask1_01.txt TLE 3154 ms 1788 KB
subtask1_02.txt RE 17 ms 1788 KB
subtask1_03.txt RE 30 ms 1788 KB
subtask1_04.txt RE 25 ms 1788 KB
subtask1_05.txt RE 19 ms 1788 KB
subtask1_06.txt RE 21 ms 1788 KB
subtask1_07.txt RE 19 ms 1788 KB
subtask1_08.txt RE 19 ms 1788 KB
subtask1_09.txt RE 20 ms 1788 KB
subtask1_10.txt RE 23 ms 1788 KB
subtask1_11.txt RE 20 ms 1788 KB
subtask1_12.txt RE 63 ms 1788 KB
subtask1_13.txt RE 32 ms 1788 KB
subtask2_01.txt TLE 3160 ms 8588 KB
subtask2_02.txt TLE 3158 ms 8716 KB
subtask2_03.txt RE 1567 ms 8716 KB
subtask2_04.txt RE 81 ms 6284 KB
subtask2_05.txt RE 2981 ms 6796 KB
subtask2_06.txt RE 123 ms 8460 KB
subtask2_07.txt TLE 3158 ms 8844 KB
subtask2_08.txt TLE 3158 ms 8588 KB
subtask2_09.txt TLE 3159 ms 8588 KB
subtask2_10.txt TLE 3158 ms 8588 KB
subtask2_11.txt TLE 3158 ms 8204 KB
subtask2_12.txt RE 137 ms 8332 KB
subtask2_13.txt RE 122 ms 8332 KB