(UPD: 2024-12-04 14:48 UTC) Judge is not working due to Cloudflare incident. (URL) We can do nothing about it, sorry. After the incident is resolved, we will grade all submissions.

Submission #819261

#TimeUsernameProblemLanguageResultExecution timeMemory
819261tengiz05Garden (JOI23_garden)C++17
30 / 100
3078 ms4180 KiB
#include <bits/stdc++.h> using i64 = long long; using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n, m, D; cin >> n >> m >> D; vector<int> p(n), q(n); for (int i = 0; i < n; i++) { cin >> p[i] >> q[i]; } vector<int> r(m), s(m); for (int i = 0; i < m; i++) { cin >> r[i] >> s[i]; } deque<pair<int, int>> g; for (int i = 0; i < m; i++) { g.push_back(pair(r[i], s[i])); } sort(g.begin(), g.end()); // deque<int> P(m); // iota(P.begin(), P.end(), 0); // sort(P.begin(), P.end(), [&](int i, int j) { // return r[i] < r[j]; // }); int ans = 1E9; for (int a = 0; a < D; a++) { while (g[0].first < a) { g.push_back({g[0].first + D, g[0].second}); g.pop_front(); } for (int b = 0; b < D; b++) { int X = a, Y = b; for (int i = 0; i < n; i++) { if (p[i] < a) X = max(X, p[i] + D); else X = max(X, p[i]); if (q[i] < b) Y = max(Y, q[i] + D); else Y = max(Y, q[i]); } // cout << a << " " << b << " " << X << " " << Y << "\n"; ans = min(ans, (max(X, g.back().first) - a + 1) * (Y - b + 1)); for (int i = m - 1; i >= 0; i--) { if (g[i].second < b) Y = max(Y, g[i].second + D); else Y = max(Y, g[i].second); if (i == 0) { ans = min(ans, (X - a + 1) * (Y - b + 1)); } else { ans = min(ans, (max(X, g[i - 1].first) - a + 1) * (Y - b + 1)); } } } } cout << ans << "\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...