Submission #856189


Source Code Expand

Copy
N = gets.to_i
X = gets.split(/ /).collect{|x| x.to_i}
L = gets.to_i
Q = gets.to_i
queries = []

d_list = []
(0...X.length - 1).each{|i|
	d_list << X[i + 1] - X[i]
}

#p d_list


Q.times{
	a, b = gets.split(/ /).collect{|x| x.to_i}
	
	a -= 1
	b -= 1
	
#	p [a, b]
	
	count = 1
	len = 0
	if a < b
		i = a
		while i < b
			len += d_list[i]
			i += 1
			if len > L
				i -= 1
				len = 0
				count += 1
			end
		end
	else
		i = a
		while i > b
			i -= 1
			len += d_list[i]
			if len > L
				i += 1
				len = 0
				count += 1
			end
		end
	end
	p count
}

Submission Info

Submission Time
Task E - Tak and Hotels
User TakaakiUmedu
Language Ruby (2.3.3)
Score 200
Code Size 601 Byte
Status TLE
Exec Time 3222 ms
Memory 10116 KB

Compile Error

./Main.rb:5: warning: assigned but unused variable - queries

Judge Result

Set Name Sample Subtask1 All
Score / Max Score 0 / 0 200 / 200 0 / 500
Status
AC × 1
AC × 14
AC × 14
TLE × 13
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 18 ms 1788 KB
subtask1_01.txt AC 18 ms 1788 KB
subtask1_02.txt AC 18 ms 1788 KB
subtask1_03.txt AC 73 ms 2300 KB
subtask1_04.txt AC 121 ms 2300 KB
subtask1_05.txt AC 68 ms 2300 KB
subtask1_06.txt AC 49 ms 1916 KB
subtask1_07.txt AC 39 ms 1916 KB
subtask1_08.txt AC 75 ms 2300 KB
subtask1_09.txt AC 79 ms 2300 KB
subtask1_10.txt AC 115 ms 2300 KB
subtask1_11.txt AC 109 ms 2300 KB
subtask1_12.txt AC 105 ms 2300 KB
subtask1_13.txt AC 98 ms 2300 KB
subtask2_01.txt TLE 3154 ms 9732 KB
subtask2_02.txt TLE 3154 ms 9604 KB
subtask2_03.txt TLE 3158 ms 10116 KB
subtask2_04.txt TLE 3154 ms 8124 KB
subtask2_05.txt TLE 3154 ms 7996 KB
subtask2_06.txt TLE 3154 ms 10116 KB
subtask2_07.txt TLE 3154 ms 9988 KB
subtask2_08.txt TLE 3154 ms 9604 KB
subtask2_09.txt TLE 3158 ms 9604 KB
subtask2_10.txt TLE 3222 ms 9732 KB
subtask2_11.txt TLE 3158 ms 9088 KB
subtask2_12.txt TLE 3158 ms 9220 KB
subtask2_13.txt TLE 3155 ms 9860 KB