Submission #856551


Source Code Expand

Copy
#include <bits/stdc++.h>
using namespace std;

#define FOR(i,l,r) for(int i = (l);i < (r);i++)
#define PB push_back
#define MP make_pair
#define ALL(x) (x).begin(),(x).end()
typedef long long ll;

int N,L,Q;
vector<int> A;
vector<int> ans;

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	cin >> N;
	A.resize(N);
	FOR(i,0,N){
		cin >> A [i];
	}
	cin >> L >> Q;
	if(N > 1000 || Q > 1000) return 0;
	ans.resize(Q);
	FOR(i,0,Q){
		int p,q;
		cin >> p >> q;
		p--,q--;
		if(p > q) swap(p,q);
		
		int day = 0;
		while(p != q){
			int r = p;
			while(r < q && A [r + 1] - A [p] <= L){
				r++;
			}
			p = r;
			day++;
		}
		ans [i] = day;
	}

	FOR(i,0,Q){
		cout << ans [i] << endl;
	}


	return 0;
}

Submission Info

Submission Time
Task E - Tak and Hotels
User gigime
Language C++14 (GCC 5.4.1)
Score 200
Code Size 759 Byte
Status WA
Exec Time 22 ms
Memory 640 KB

Judge Result

Set Name Sample Subtask1 All
Score / Max Score 0 / 0 200 / 200 0 / 500
Status
AC × 1
AC × 14
AC × 14
WA × 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 4 ms 256 KB
subtask1_01.txt AC 4 ms 256 KB
subtask1_02.txt AC 4 ms 256 KB
subtask1_03.txt AC 10 ms 256 KB
subtask1_04.txt AC 11 ms 256 KB
subtask1_05.txt AC 10 ms 256 KB
subtask1_06.txt AC 7 ms 256 KB
subtask1_07.txt AC 7 ms 256 KB
subtask1_08.txt AC 10 ms 256 KB
subtask1_09.txt AC 11 ms 256 KB
subtask1_10.txt AC 11 ms 256 KB
subtask1_11.txt AC 11 ms 256 KB
subtask1_12.txt AC 11 ms 256 KB
subtask1_13.txt AC 11 ms 256 KB
subtask2_01.txt WA 18 ms 640 KB
subtask2_02.txt WA 22 ms 640 KB
subtask2_03.txt WA 22 ms 640 KB
subtask2_04.txt WA 16 ms 512 KB
subtask2_05.txt WA 16 ms 512 KB
subtask2_06.txt WA 22 ms 640 KB
subtask2_07.txt WA 22 ms 640 KB
subtask2_08.txt WA 21 ms 640 KB
subtask2_09.txt WA 21 ms 640 KB
subtask2_10.txt WA 22 ms 640 KB
subtask2_11.txt WA 20 ms 640 KB
subtask2_12.txt WA 21 ms 640 KB
subtask2_13.txt WA 20 ms 640 KB