#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
int N,K,Q;
cin>>N>>K>>Q;
vector<int> X(N),T(N),A(N),B(N);
vector<vector<tuple<int,int,int>>> G(K);
vector<multiset<tuple<int,int,int>>> sta(K);
vector<multiset<int>> Z(K);
vector<int> I(K,0);
for(int i=0;i<N;i++){
cin>>X[i]>>T[i]>>A[i]>>B[i];
T[i]--;
G[T[i]].push_back({A[i],B[i],X[i]});
}
for(int i=0;i<K;i++){
sort(G[i].begin(),G[i].end());
}
vector<pair<int,int>> Que(Q);
for(int i=0;i<Q;i++) cin>>Que[i].second>>Que[i].first;
vector<pair<int,int>> Que_ = Que;
sort(Que.begin(),Que.end());
map<pair<int,int>,int> m_ans;
for(int i=0;i<Q;i++){
int t = Que[i].first, x = Que[i].second;
for(int j=0;j<K;j++){
while(I[j] != G[j].size()){
int aa,bb,cc;
tie(aa,bb,cc) = G[j][I[j]];
if(aa > t) break;
sta[j].insert({bb,aa,cc});
Z[j].insert(cc);
I[j]++;
}
}
for(int j=0;j<K;j++){
while(!sta[j].empty()){
auto pos = *sta[j].begin();
int bb,aa,cc;
tie(bb,aa,cc) = pos;
if(bb > t) break;
sta[j].erase(sta[j].find(pos));
Z[j].erase(Z[j].find(cc));
}
}
int ans = 0;
for(int j=0;j<K;j++){
int now = 1e18;
if(sta[j].empty()){
ans = 1e18;
continue;
}
auto a = Z[j].lower_bound(x);
if(a != Z[j].end()){
now = min(now,abs(x-(*a)));
}
if(a != Z[j].begin()){
a--;
now = min(now,abs(x-(*a)));
}
ans = max(ans,now);
}
cout<<ans<<endl;
}
}
Compilation message
new_home.cpp: In function 'int main()':
new_home.cpp:28:18: warning: comparison of integer expressions of different signedness: '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'} and 'std::vector<std::tuple<long long int, long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
28 | while(I[j] != G[j].size()){
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
5047 ms |
83308 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
5046 ms |
75144 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |