#include<bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define in insert
#define pb push_back
#define ppb pop_back()
#define d3 ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define cans cout << ans << "\n";
#define yes cout << "Yes" << "\n";
#define no cout << "No" << "\n";
#define pll pair<ll,ll>
#define lin cout << "\n";
#define sqr 340
#define mod 1000000007
#define mid ((l+r)/2)
#define lc (2*n)
#define rc (2*n+1)
using namespace std;
ll fp(ll x , ll y)
{
if(y==0)
return 1;
ll z = fp(x,y/2);
if(y&1)
return z*z%mod*x%mod;
else
return z*z%mod;
}
int sqrot(ll x)
{
int l = 0 , r = INT_MAX;
while(l<=r)
{
if(mid*mid>=x)
r=mid-1;
else
l=mid+1;
}
return r+1;
}
ll cel(ll x , ll y)
{
return x/y + bool(x%y);
}
pair<pll,pll> a[60009];
pair<pll,ll> w[60009];
ll l[60009];
ll y[60009];
multiset<pll> s1[409] , s2[409];
int main()
{
d3
ll n , k , q;
cin >> n >> k >> q;
for(int i = 0 ; n>i ; i++)
cin >> a[i].S.F >> a[i].S.S >> a[i].F.F >> a[i].F.S;
for(int i = 0 ; q>i ; i++)
{
cin >> w[i].F.S >> w[i].F.F;
w[i].S=i;
}
sort(w,w+q);
for(int i = 0 ; q>i ; i++)
{
l[i]=w[i].F.S;
y[i]=w[i].F.F;
}
ll idx = 0;
for(int i = 0 ; q>i ; i++)
{
ll t = y[i];
ll c = l[i];
for(;n>idx;idx++)
{
if(a[idx].F.F>t)
break;
s1[a[idx].S.S].in({a[idx].S.F,a[idx].F.S});
s2[a[idx].S.S].in({a[idx].F.S,a[idx].S.F});
}
ll ans = 0;
for(int j = 1 ; k>=j ; j++)
{
while(!s2[j].empty())
{
auto it = s2[j].begin();
if(it->F>=t)
break;
s1[j].erase(s1[j].find({it->S,it->F}));
s2[j].erase(it);
}
if(s1[j].empty())
ans=-1;
if(ans==-1)
continue;
auto it = s1[j].upper_bound({c,0});
ll ans1 = 1e10;
if(it!=s1[j].end())
ans1=min(ans1,it->F-c);
if(it!=s1[j].begin())
{
it--;
ans1=min(ans1,c-it->F);
}
ans=max(ans1,ans);
}
cans
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4440 KB |
Output is correct |
2 |
Correct |
1 ms |
4444 KB |
Output is correct |
3 |
Correct |
1 ms |
4444 KB |
Output is correct |
4 |
Incorrect |
1 ms |
4444 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4440 KB |
Output is correct |
2 |
Correct |
1 ms |
4444 KB |
Output is correct |
3 |
Correct |
1 ms |
4444 KB |
Output is correct |
4 |
Incorrect |
1 ms |
4444 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
20 ms |
6564 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
16 ms |
6236 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4440 KB |
Output is correct |
2 |
Correct |
1 ms |
4444 KB |
Output is correct |
3 |
Correct |
1 ms |
4444 KB |
Output is correct |
4 |
Incorrect |
1 ms |
4444 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4440 KB |
Output is correct |
2 |
Correct |
1 ms |
4444 KB |
Output is correct |
3 |
Correct |
1 ms |
4444 KB |
Output is correct |
4 |
Incorrect |
1 ms |
4444 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |