#include <bits/stdc++.h>
#define ALL(x) x.begin(),x.end()
struct Store
{
long pos;
long type;
long oYear;
long cYear;
};
int main()
{
long numStores, numTypes, numQ;
std::cin >> numStores;
std::cin >> numTypes;
std::cin >> numQ;
std::vector<Store> stores(numStores);
for (long s = 0; s < numStores; s++)
{
std::cin >> stores[s].pos;
std::cin >> stores[s].type;
std::cin >> stores[s].oYear;
std::cin >> stores[s].cYear;
stores[s].type--;
}
std::vector<long> minDist(numTypes);
for (long i = 0; i < numQ; i++)
{
long pos, year;
std::cin >> pos;
std::cin >> year;
std::fill(ALL(minDist), -1);
for (long s = 0; s < numStores; s++)
{
if (stores[s].cYear < year || stores[s].oYear > year)
continue;
long dist = std::abs(stores[s].pos - pos);
long& curDist = minDist[stores[s].type];
if (curDist == -1 || dist < curDist)
curDist = dist;
}
long inconv = -1;
for (long d : minDist)
{
if (d == -1)
{
inconv = -1;
break;
}
inconv = std::max(inconv, d);
}
std::cout << inconv << std::endl;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
340 KB |
Output is correct |
2 |
Correct |
2 ms |
360 KB |
Output is correct |
3 |
Correct |
1 ms |
436 KB |
Output is correct |
4 |
Correct |
3 ms |
480 KB |
Output is correct |
5 |
Correct |
5 ms |
512 KB |
Output is correct |
6 |
Correct |
7 ms |
704 KB |
Output is correct |
7 |
Correct |
6 ms |
704 KB |
Output is correct |
8 |
Correct |
7 ms |
720 KB |
Output is correct |
9 |
Correct |
7 ms |
888 KB |
Output is correct |
10 |
Correct |
5 ms |
940 KB |
Output is correct |
11 |
Correct |
5 ms |
944 KB |
Output is correct |
12 |
Correct |
5 ms |
944 KB |
Output is correct |
13 |
Correct |
5 ms |
944 KB |
Output is correct |
14 |
Correct |
6 ms |
948 KB |
Output is correct |
15 |
Correct |
5 ms |
968 KB |
Output is correct |
16 |
Correct |
5 ms |
988 KB |
Output is correct |
17 |
Correct |
5 ms |
1008 KB |
Output is correct |
18 |
Correct |
6 ms |
1028 KB |
Output is correct |
19 |
Correct |
5 ms |
1044 KB |
Output is correct |
20 |
Correct |
5 ms |
1068 KB |
Output is correct |
21 |
Correct |
5 ms |
1088 KB |
Output is correct |
22 |
Correct |
7 ms |
1232 KB |
Output is correct |
23 |
Correct |
7 ms |
1232 KB |
Output is correct |
24 |
Correct |
7 ms |
1232 KB |
Output is correct |
25 |
Correct |
6 ms |
1232 KB |
Output is correct |
26 |
Correct |
7 ms |
1232 KB |
Output is correct |
27 |
Correct |
4 ms |
1232 KB |
Output is correct |
28 |
Correct |
6 ms |
1232 KB |
Output is correct |
29 |
Correct |
5 ms |
1232 KB |
Output is correct |
30 |
Correct |
5 ms |
1252 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
340 KB |
Output is correct |
2 |
Correct |
2 ms |
360 KB |
Output is correct |
3 |
Correct |
1 ms |
436 KB |
Output is correct |
4 |
Correct |
3 ms |
480 KB |
Output is correct |
5 |
Correct |
5 ms |
512 KB |
Output is correct |
6 |
Correct |
7 ms |
704 KB |
Output is correct |
7 |
Correct |
6 ms |
704 KB |
Output is correct |
8 |
Correct |
7 ms |
720 KB |
Output is correct |
9 |
Correct |
7 ms |
888 KB |
Output is correct |
10 |
Correct |
5 ms |
940 KB |
Output is correct |
11 |
Correct |
5 ms |
944 KB |
Output is correct |
12 |
Correct |
5 ms |
944 KB |
Output is correct |
13 |
Correct |
5 ms |
944 KB |
Output is correct |
14 |
Correct |
6 ms |
948 KB |
Output is correct |
15 |
Correct |
5 ms |
968 KB |
Output is correct |
16 |
Correct |
5 ms |
988 KB |
Output is correct |
17 |
Correct |
5 ms |
1008 KB |
Output is correct |
18 |
Correct |
6 ms |
1028 KB |
Output is correct |
19 |
Correct |
5 ms |
1044 KB |
Output is correct |
20 |
Correct |
5 ms |
1068 KB |
Output is correct |
21 |
Correct |
5 ms |
1088 KB |
Output is correct |
22 |
Correct |
7 ms |
1232 KB |
Output is correct |
23 |
Correct |
7 ms |
1232 KB |
Output is correct |
24 |
Correct |
7 ms |
1232 KB |
Output is correct |
25 |
Correct |
6 ms |
1232 KB |
Output is correct |
26 |
Correct |
7 ms |
1232 KB |
Output is correct |
27 |
Correct |
4 ms |
1232 KB |
Output is correct |
28 |
Correct |
6 ms |
1232 KB |
Output is correct |
29 |
Correct |
5 ms |
1232 KB |
Output is correct |
30 |
Correct |
5 ms |
1252 KB |
Output is correct |
31 |
Execution timed out |
5066 ms |
5736 KB |
Time limit exceeded |
32 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
5057 ms |
13416 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
5097 ms |
13416 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
340 KB |
Output is correct |
2 |
Correct |
2 ms |
360 KB |
Output is correct |
3 |
Correct |
1 ms |
436 KB |
Output is correct |
4 |
Correct |
3 ms |
480 KB |
Output is correct |
5 |
Correct |
5 ms |
512 KB |
Output is correct |
6 |
Correct |
7 ms |
704 KB |
Output is correct |
7 |
Correct |
6 ms |
704 KB |
Output is correct |
8 |
Correct |
7 ms |
720 KB |
Output is correct |
9 |
Correct |
7 ms |
888 KB |
Output is correct |
10 |
Correct |
5 ms |
940 KB |
Output is correct |
11 |
Correct |
5 ms |
944 KB |
Output is correct |
12 |
Correct |
5 ms |
944 KB |
Output is correct |
13 |
Correct |
5 ms |
944 KB |
Output is correct |
14 |
Correct |
6 ms |
948 KB |
Output is correct |
15 |
Correct |
5 ms |
968 KB |
Output is correct |
16 |
Correct |
5 ms |
988 KB |
Output is correct |
17 |
Correct |
5 ms |
1008 KB |
Output is correct |
18 |
Correct |
6 ms |
1028 KB |
Output is correct |
19 |
Correct |
5 ms |
1044 KB |
Output is correct |
20 |
Correct |
5 ms |
1068 KB |
Output is correct |
21 |
Correct |
5 ms |
1088 KB |
Output is correct |
22 |
Correct |
7 ms |
1232 KB |
Output is correct |
23 |
Correct |
7 ms |
1232 KB |
Output is correct |
24 |
Correct |
7 ms |
1232 KB |
Output is correct |
25 |
Correct |
6 ms |
1232 KB |
Output is correct |
26 |
Correct |
7 ms |
1232 KB |
Output is correct |
27 |
Correct |
4 ms |
1232 KB |
Output is correct |
28 |
Correct |
6 ms |
1232 KB |
Output is correct |
29 |
Correct |
5 ms |
1232 KB |
Output is correct |
30 |
Correct |
5 ms |
1252 KB |
Output is correct |
31 |
Execution timed out |
5066 ms |
5736 KB |
Time limit exceeded |
32 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
340 KB |
Output is correct |
2 |
Correct |
2 ms |
360 KB |
Output is correct |
3 |
Correct |
1 ms |
436 KB |
Output is correct |
4 |
Correct |
3 ms |
480 KB |
Output is correct |
5 |
Correct |
5 ms |
512 KB |
Output is correct |
6 |
Correct |
7 ms |
704 KB |
Output is correct |
7 |
Correct |
6 ms |
704 KB |
Output is correct |
8 |
Correct |
7 ms |
720 KB |
Output is correct |
9 |
Correct |
7 ms |
888 KB |
Output is correct |
10 |
Correct |
5 ms |
940 KB |
Output is correct |
11 |
Correct |
5 ms |
944 KB |
Output is correct |
12 |
Correct |
5 ms |
944 KB |
Output is correct |
13 |
Correct |
5 ms |
944 KB |
Output is correct |
14 |
Correct |
6 ms |
948 KB |
Output is correct |
15 |
Correct |
5 ms |
968 KB |
Output is correct |
16 |
Correct |
5 ms |
988 KB |
Output is correct |
17 |
Correct |
5 ms |
1008 KB |
Output is correct |
18 |
Correct |
6 ms |
1028 KB |
Output is correct |
19 |
Correct |
5 ms |
1044 KB |
Output is correct |
20 |
Correct |
5 ms |
1068 KB |
Output is correct |
21 |
Correct |
5 ms |
1088 KB |
Output is correct |
22 |
Correct |
7 ms |
1232 KB |
Output is correct |
23 |
Correct |
7 ms |
1232 KB |
Output is correct |
24 |
Correct |
7 ms |
1232 KB |
Output is correct |
25 |
Correct |
6 ms |
1232 KB |
Output is correct |
26 |
Correct |
7 ms |
1232 KB |
Output is correct |
27 |
Correct |
4 ms |
1232 KB |
Output is correct |
28 |
Correct |
6 ms |
1232 KB |
Output is correct |
29 |
Correct |
5 ms |
1232 KB |
Output is correct |
30 |
Correct |
5 ms |
1252 KB |
Output is correct |
31 |
Execution timed out |
5066 ms |
5736 KB |
Time limit exceeded |
32 |
Halted |
0 ms |
0 KB |
- |