#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll inf = 1e13;
#define int ll
using pii = pair<int, int>;
#define fr first
#define sc second
signed main() {
int n, q, d, a, b;
cin >> n >> q >> d >> a >> b;
//a = 1, b = d;
vector<pii> inter;
int jump = inf;
for (int i = 1; i <= n; i ++) {
int x, y;
cin >> x >> y;
inter.push_back({x, y});
if (y - x + 2 >= d) {
jump = min(jump, x - 1);
}
}
int lastBefore = 0, crash = inf;
for (int i = 0; i < n; i ++) {
lastBefore = max(lastBefore + d, inter[i].sc + 1);
if (i < n - 1 && lastBefore >= inter[i + 1].fr) {
crash = inter[i].fr - 1;
break;
}
}
crash = min(crash, jump);
for (int i = 0; i < q; i ++) {
int x;
cin >> x;
if (x <= crash)
cout << x << '\n';
else
cout << -1 << '\n';
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |