提交时间:2025-05-27 14:24:28

运行 ID: 193895

#include <iostream> #include <vector> #include <algorithm> #include <cmath> using namespace std; struct Point { int x; int y; bool operator<(const Point& other) const { if (x != other.x) return x < other.x; return y < other.y; } }; int main() { int N, M; cin >> N >> M; int K; cin >> K; vector<Point> points; for (int i = 0; i < K; ++i) { int a, b; cin >> a >> b; points.push_back({a, b}); } sort(points.begin(), points.end()); vector<int> dp(K, 1); for (int i = 0; i < K; ++i) { for (int j = 0; j < i; ++j) { if (points[j].x <= points[i].x && points[j].y <= points[i].y) { if (dp[j] + 1 > dp[i]) { dp[i] = dp[j] + 1; } } } } int max_len = 0; for (int len : dp) { if (len > max_len) { max_len = len; } } double diag = max_len * 100 * sqrt(2); double straight = (N + M - 2 * max_len) * 100.0; double total = diag + straight; cout << static_cast<int>(round(total)) << endl; return 0; }