# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
59232 | Just_Solve_The_Problem | New Home (APIO18_new_home) | C++11 | 428 ms | 8616 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define pii pair < int, int >
#define fr first
#define sc second
#define mk make_pair
#define pb push_back
#define sz(s) (int)s.size()
#define all(s) s.begin(), s.end()
const int N = (int)3e5 + 7;
const int inf = (int)1e9 + 7;
int n, k, q;
int x[N], t[N], a[N], b[N];
pii ar[N];
vector < int > pos;
int cur[N];
vector < pii > query;
bool has[N];
main() {
scanf("%d %d %d", &n, &k, &q);
for (int i = 1; i <= n; i++) {
scanf("%d %d %d %d", &ar[i].fr, &ar[i].sc, &a[i], &b[i]);
has[ar[i].sc] = 1;
pos.pb(ar[i].fr);
}
for (int i = 1; i <= k; i++) {
if (!has[i]) {
for (int j = 1; j <= q; j++) {
puts("-1");
}
return 0;
}
}
sort(all(pos));
for (int i = 1; i <= q; i++) {
int l, y;
scanf("%d %d", &l, &y);
int pos1 = lower_bound(all(pos), l) - pos.begin();
int ans = inf;
if (pos1 < sz(pos))
ans = min(ans, pos[pos1] - l);
if (pos1)
ans = min(ans, l - pos[pos1 - 1]);
printf("%d\n", ans);
}
}
Compilation message (stderr)
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |