Submission #59863

#TimeUsernameProblemLanguageResultExecution timeMemory
59863Eae02New Home (APIO18_new_home)C++14
5 / 100
5097 ms13416 KiB
#include <bits/stdc++.h> #define ALL(x) x.begin(),x.end() struct Store { long pos; long type; long oYear; long cYear; }; int main() { long numStores, numTypes, numQ; std::cin >> numStores; std::cin >> numTypes; std::cin >> numQ; std::vector<Store> stores(numStores); for (long s = 0; s < numStores; s++) { std::cin >> stores[s].pos; std::cin >> stores[s].type; std::cin >> stores[s].oYear; std::cin >> stores[s].cYear; stores[s].type--; } std::vector<long> minDist(numTypes); for (long i = 0; i < numQ; i++) { long pos, year; std::cin >> pos; std::cin >> year; std::fill(ALL(minDist), -1); for (long s = 0; s < numStores; s++) { if (stores[s].cYear < year || stores[s].oYear > year) continue; long dist = std::abs(stores[s].pos - pos); long& curDist = minDist[stores[s].type]; if (curDist == -1 || dist < curDist) curDist = dist; } long inconv = -1; for (long d : minDist) { if (d == -1) { inconv = -1; break; } inconv = std::max(inconv, d); } std::cout << inconv << std::endl; } }
#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...