Submission #962647

#TimeUsernameProblemLanguageResultExecution timeMemory
962647vjudge1New Home (APIO18_new_home)C++17
5 / 100
5095 ms22208 KiB
#include <bits/stdc++.h> using namespace std; #define int long long signed main(){ int n, k, q; cin >> n >> k >> q; int x[n], t[n], a[n], b[n]; for (int i=0; i<n; i++){ cin >> x[i] >> t[i] >> a[i] >> b[i]; } while(q--){ int l, y; cin >> l >> y; bool isopen[n], hastype[k]; memset(isopen, false, sizeof(isopen)); memset(hastype, false, sizeof(hastype)); map<int, int> mp; //mp[type] = min dist for (int i=0; i<n; i++){ if(y>=a[i] && y<=b[i]){ // shop is open isopen[i] = true; if(hastype[t[i]-1]==true) mp[t[i]-1] = min(mp[t[i]-1], abs(x[i]-l)); else{ mp[t[i]-1] = abs(x[i]-l); hastype[t[i]-1] = true; } } } bool done = false; for (int i=0; i<k; i++){ if(hastype[i]==false){ //not all types open cout << "-1\n"; done = true; break; } } if(done==false){ int inconv = 0; for (int i=0; i<k; i++){ inconv = max(inconv, mp[i]); } cout << inconv << "\n"; } } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...