이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define fast cin.tie(0)->sync_with_stdio(0);
#define int long long
#define inf ((int)1e18)
using namespace std;
int32_t main(){
fast
int n, k, q;
cin >> n >> k >> q;
vector <array<int, 4> > arr;
for(int i = 0; i < n; i++) {
int x, t, a, b;
cin >> x >> t >> a >> b;
t--;
arr.push_back({x, t, a, b});
}
while(q--) {
int x, t;
cin >> x >> t;
vector <int> mins(k, inf);
for(auto [pos, type, a, b]:arr) {
if(t >= a and t <= b) {
mins[type] = min(mins[type], abs(pos - x));
}
}
int ans = 0;
for(auto it:mins) {
ans = max(ans, it);
}
cout << (ans == inf ? -1 : ans) << '\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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |