#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
int n, k, q;
cin >> n >> k >> q;
int x[n], t[n], a[n], b[n];
for (int i=0; i<n; i++){
cin >> x[i] >> t[i] >> a[i] >> b[i];
}
while(q--){
int l, y;
cin >> l >> y;
bool isopen[n], hastype[k];
memset(isopen, false, sizeof(isopen));
memset(hastype, false, sizeof(hastype));
map<int, int> mp; //mp[type] = min dist
for (int i=0; i<n; i++){
if(y>=a[i] && y<=b[i]){ // shop is open
isopen[i] = true;
if(hastype[t[i]-1]==true) mp[t[i]-1] = min(mp[t[i]-1], abs(x[i]-l));
else{
mp[t[i]-1] = abs(x[i]-l);
hastype[t[i]-1] = true;
}
}
}
bool done = false;
for (int i=0; i<k; i++){
if(hastype[i]==false){ //not all types open
cout << "-1\n";
done = true;
break;
}
}
if(done==false){
int inconv = 0;
for (int i=0; i<k; i++){
inconv = max(inconv, mp[i]);
}
cout << inconv << "\n";
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
2 ms |
348 KB |
Output is correct |
6 |
Correct |
3 ms |
348 KB |
Output is correct |
7 |
Correct |
5 ms |
348 KB |
Output is correct |
8 |
Correct |
10 ms |
348 KB |
Output is correct |
9 |
Correct |
9 ms |
348 KB |
Output is correct |
10 |
Correct |
4 ms |
344 KB |
Output is correct |
11 |
Correct |
2 ms |
344 KB |
Output is correct |
12 |
Correct |
2 ms |
348 KB |
Output is correct |
13 |
Correct |
2 ms |
344 KB |
Output is correct |
14 |
Correct |
2 ms |
348 KB |
Output is correct |
15 |
Correct |
5 ms |
348 KB |
Output is correct |
16 |
Correct |
6 ms |
348 KB |
Output is correct |
17 |
Correct |
4 ms |
348 KB |
Output is correct |
18 |
Correct |
5 ms |
348 KB |
Output is correct |
19 |
Correct |
6 ms |
348 KB |
Output is correct |
20 |
Correct |
3 ms |
348 KB |
Output is correct |
21 |
Correct |
11 ms |
348 KB |
Output is correct |
22 |
Correct |
11 ms |
348 KB |
Output is correct |
23 |
Correct |
6 ms |
348 KB |
Output is correct |
24 |
Correct |
5 ms |
348 KB |
Output is correct |
25 |
Correct |
5 ms |
448 KB |
Output is correct |
26 |
Correct |
2 ms |
348 KB |
Output is correct |
27 |
Correct |
2 ms |
348 KB |
Output is correct |
28 |
Correct |
2 ms |
344 KB |
Output is correct |
29 |
Correct |
2 ms |
348 KB |
Output is correct |
30 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
2 ms |
348 KB |
Output is correct |
6 |
Correct |
3 ms |
348 KB |
Output is correct |
7 |
Correct |
5 ms |
348 KB |
Output is correct |
8 |
Correct |
10 ms |
348 KB |
Output is correct |
9 |
Correct |
9 ms |
348 KB |
Output is correct |
10 |
Correct |
4 ms |
344 KB |
Output is correct |
11 |
Correct |
2 ms |
344 KB |
Output is correct |
12 |
Correct |
2 ms |
348 KB |
Output is correct |
13 |
Correct |
2 ms |
344 KB |
Output is correct |
14 |
Correct |
2 ms |
348 KB |
Output is correct |
15 |
Correct |
5 ms |
348 KB |
Output is correct |
16 |
Correct |
6 ms |
348 KB |
Output is correct |
17 |
Correct |
4 ms |
348 KB |
Output is correct |
18 |
Correct |
5 ms |
348 KB |
Output is correct |
19 |
Correct |
6 ms |
348 KB |
Output is correct |
20 |
Correct |
3 ms |
348 KB |
Output is correct |
21 |
Correct |
11 ms |
348 KB |
Output is correct |
22 |
Correct |
11 ms |
348 KB |
Output is correct |
23 |
Correct |
6 ms |
348 KB |
Output is correct |
24 |
Correct |
5 ms |
348 KB |
Output is correct |
25 |
Correct |
5 ms |
448 KB |
Output is correct |
26 |
Correct |
2 ms |
348 KB |
Output is correct |
27 |
Correct |
2 ms |
348 KB |
Output is correct |
28 |
Correct |
2 ms |
344 KB |
Output is correct |
29 |
Correct |
2 ms |
348 KB |
Output is correct |
30 |
Correct |
1 ms |
348 KB |
Output is correct |
31 |
Execution timed out |
5038 ms |
4452 KB |
Time limit exceeded |
32 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
5095 ms |
22208 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
5094 ms |
17976 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
2 ms |
348 KB |
Output is correct |
6 |
Correct |
3 ms |
348 KB |
Output is correct |
7 |
Correct |
5 ms |
348 KB |
Output is correct |
8 |
Correct |
10 ms |
348 KB |
Output is correct |
9 |
Correct |
9 ms |
348 KB |
Output is correct |
10 |
Correct |
4 ms |
344 KB |
Output is correct |
11 |
Correct |
2 ms |
344 KB |
Output is correct |
12 |
Correct |
2 ms |
348 KB |
Output is correct |
13 |
Correct |
2 ms |
344 KB |
Output is correct |
14 |
Correct |
2 ms |
348 KB |
Output is correct |
15 |
Correct |
5 ms |
348 KB |
Output is correct |
16 |
Correct |
6 ms |
348 KB |
Output is correct |
17 |
Correct |
4 ms |
348 KB |
Output is correct |
18 |
Correct |
5 ms |
348 KB |
Output is correct |
19 |
Correct |
6 ms |
348 KB |
Output is correct |
20 |
Correct |
3 ms |
348 KB |
Output is correct |
21 |
Correct |
11 ms |
348 KB |
Output is correct |
22 |
Correct |
11 ms |
348 KB |
Output is correct |
23 |
Correct |
6 ms |
348 KB |
Output is correct |
24 |
Correct |
5 ms |
348 KB |
Output is correct |
25 |
Correct |
5 ms |
448 KB |
Output is correct |
26 |
Correct |
2 ms |
348 KB |
Output is correct |
27 |
Correct |
2 ms |
348 KB |
Output is correct |
28 |
Correct |
2 ms |
344 KB |
Output is correct |
29 |
Correct |
2 ms |
348 KB |
Output is correct |
30 |
Correct |
1 ms |
348 KB |
Output is correct |
31 |
Execution timed out |
5038 ms |
4452 KB |
Time limit exceeded |
32 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
2 ms |
348 KB |
Output is correct |
6 |
Correct |
3 ms |
348 KB |
Output is correct |
7 |
Correct |
5 ms |
348 KB |
Output is correct |
8 |
Correct |
10 ms |
348 KB |
Output is correct |
9 |
Correct |
9 ms |
348 KB |
Output is correct |
10 |
Correct |
4 ms |
344 KB |
Output is correct |
11 |
Correct |
2 ms |
344 KB |
Output is correct |
12 |
Correct |
2 ms |
348 KB |
Output is correct |
13 |
Correct |
2 ms |
344 KB |
Output is correct |
14 |
Correct |
2 ms |
348 KB |
Output is correct |
15 |
Correct |
5 ms |
348 KB |
Output is correct |
16 |
Correct |
6 ms |
348 KB |
Output is correct |
17 |
Correct |
4 ms |
348 KB |
Output is correct |
18 |
Correct |
5 ms |
348 KB |
Output is correct |
19 |
Correct |
6 ms |
348 KB |
Output is correct |
20 |
Correct |
3 ms |
348 KB |
Output is correct |
21 |
Correct |
11 ms |
348 KB |
Output is correct |
22 |
Correct |
11 ms |
348 KB |
Output is correct |
23 |
Correct |
6 ms |
348 KB |
Output is correct |
24 |
Correct |
5 ms |
348 KB |
Output is correct |
25 |
Correct |
5 ms |
448 KB |
Output is correct |
26 |
Correct |
2 ms |
348 KB |
Output is correct |
27 |
Correct |
2 ms |
348 KB |
Output is correct |
28 |
Correct |
2 ms |
344 KB |
Output is correct |
29 |
Correct |
2 ms |
348 KB |
Output is correct |
30 |
Correct |
1 ms |
348 KB |
Output is correct |
31 |
Execution timed out |
5038 ms |
4452 KB |
Time limit exceeded |
32 |
Halted |
0 ms |
0 KB |
- |