Files
2026-05-18 15:26:14 +08:00

43 lines
845 B
C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
using namespace std;
int main() {
int n;
cin >> n;
vector<pair<int,int>> points(n);
for(int i = 0; i < n; i++) {
cin >> points[i].first >> points[i].second;
}
sort(points.begin(), points.end(),
[](const pair<int,int>& a, const pair<int,int>& b) {
if(a.first == b.first)
return a.second > b.second;
return a.first > b.first; // x降序
});
vector<pair<int,int>> ans;
int ymax = INT_MIN;
for(auto &p : points) {
if(p.second > ymax) {
ans.push_back(p);
ymax = p.second;
}
}
reverse(ans.begin(), ans.end());
for(auto &p : ans) {
cout << "(" << p.first << "," << p.second << ")";
}
return 0;
}