Submission #855955


Source Code Expand

Copy
#include <bits/stdc++.h>
using namespace std;
int N, L, Q;
vector<int> x;
int main() {
	cin >> N;
	x.resize(N);
	for (int& s : x) cin >> s;
	cin >> L >> Q;
	if (L > 1000 || Q > 1000) throw 1;
	for (int i = 0; i < Q; ++ i) {
		int a, b;
		cin >> a >> b;
		-- a; -- b;
		int p = a < b ? 1 : -1;
		int d = 1;
		long long e = 0;
		for (int j = a; j != b; j += p) {
			int f = abs(x[j] - x[j + p]);
			if (e + f <= L) {
				e += f;
			} else {
				e = f;
				++ d;
			}
		}
		cout << d << endl;
	}
}

Submission Info

Submission Time
Task E - Tak and Hotels
User hasi
Language C++14 (GCC 5.4.1)
Score 0
Code Size 524 Byte
Status RE
Exec Time 277 ms
Memory 640 KB

Judge Result

Set Name Sample Subtask1 All
Score / Max Score 0 / 0 0 / 200 0 / 500
Status
AC × 1
AC × 3
RE × 11
AC × 3
RE × 24
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 4 ms 256 KB
subtask1_01.txt AC 5 ms 256 KB
subtask1_02.txt RE 194 ms 256 KB
subtask1_03.txt AC 14 ms 256 KB
subtask1_04.txt RE 197 ms 256 KB
subtask1_05.txt RE 195 ms 256 KB
subtask1_06.txt RE 193 ms 256 KB
subtask1_07.txt RE 192 ms 256 KB
subtask1_08.txt RE 194 ms 256 KB
subtask1_09.txt RE 192 ms 256 KB
subtask1_10.txt RE 194 ms 256 KB
subtask1_11.txt RE 192 ms 256 KB
subtask1_12.txt RE 193 ms 256 KB
subtask1_13.txt RE 193 ms 256 KB
subtask2_01.txt RE 259 ms 640 KB
subtask2_02.txt RE 271 ms 640 KB
subtask2_03.txt RE 271 ms 640 KB
subtask2_04.txt RE 245 ms 512 KB
subtask2_05.txt RE 255 ms 512 KB
subtask2_06.txt RE 274 ms 640 KB
subtask2_07.txt RE 277 ms 640 KB
subtask2_08.txt RE 269 ms 640 KB
subtask2_09.txt RE 264 ms 640 KB
subtask2_10.txt RE 267 ms 640 KB
subtask2_11.txt RE 264 ms 640 KB
subtask2_12.txt RE 264 ms 640 KB
subtask2_13.txt RE 262 ms 640 KB