Submission #288520

# Submission time Handle Problem Language Result Execution time Memory
288520 2020-09-01T15:02:09 Z ScarletS New Home (APIO18_new_home) C++17
0 / 100
5000 ms 65016 KB
#include <bits/stdc++.h>
#define ll long long
#define sz(x) (int)(x).size();
#define pii pair<int,int>
#define f first
#define s second
using namespace std;

const int MAXN=3e5+7;
int n,k,x,y,ans,INF=1e9,cur;
set<int> typesF[MAXN];
set<int,greater<int>> typesB[MAXN];

ll solve()
{
	ans=0;
	cin>>x>>y;
	for (int i=1;i<=k;++i)	
	{
		cur=INF;
		if (typesF[i].lower_bound(x)!=typesF[i].end())
			cur=(*(typesF[i].lower_bound(x)))-x;
		if (typesB[i].lower_bound(x)!=typesB[i].end())
			cur=min(cur,x-(*(typesB[i].lower_bound(x))));
		ans=max(ans,cur);
	}
	if (ans==INF)
		return -1;
	return ans;
}

int main()
{
	int q,x_i,t_i,a_i,b_i;
	cin>>n>>k>>q;
	for (int i=0;i<n;++i)
	{
		cin>>x_i>>t_i>>a_i>>b_i;
		typesF[t_i].insert(x_i);
		typesB[t_i].insert(x_i);
	}
	while (q--)
		cout<<solve()<<"\n";
}
# Verdict Execution time Memory Grader output
1 Correct 19 ms 28544 KB Output is correct
2 Incorrect 19 ms 28544 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 19 ms 28544 KB Output is correct
2 Incorrect 19 ms 28544 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 5100 ms 65016 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 5057 ms 64504 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 19 ms 28544 KB Output is correct
2 Incorrect 19 ms 28544 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 19 ms 28544 KB Output is correct
2 Incorrect 19 ms 28544 KB Output isn't correct
3 Halted 0 ms 0 KB -