#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pb push_back
#define endl '\n'
#define all(x) x.begin(),x.end()
#define yes cout<<"Yes"<<endl
#define no cout<<"No"<<endl
const int N = 1e6,mod = 1e9+7;
ll X[N];
ll A[N];
ll B[N];
ll K[N];
ll ans[N];
int main()
{
ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int n,q,k;
cin>>n>>k>>q;
for(int i = 0;i<n;i++)
{
cin>>X[i];
cin>>K[i];
cin>>A[i];
cin>>B[i];
}
while(q--)
{
int x,t;
cin>>x>>t;
for(int i = 1;i<=k;i++)
ans[i] = 1e18;
for(int i = 0;i<n;i++)
{
if(A[i]<=t&&B[i]>=t)
{
ans[K[i]] = min(ans[K[i]],abs(x-X[i]));
}
}
int out = 0;
for(int i = 1;i<=k;i++)
out+=ans[i];
if(out>=1e18)
out = -1;
cout<<out<<endl;
}
return 0;
}
/*
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
5032 ms |
10248 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
5067 ms |
9928 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |