AT_abc348_c 题解
思路
表示对于所有 ,其中最小的 。然后这题就变成了 。因为 大,所以可以用 map 存哦!
代码
# include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
int n, x, y, maxx;
map <int, int> f;
int main () {
ios::sync_with_stdio (0);
cin.tie (0);
cout.tie (0);
cin >> n;
for (int i = 0; i < n; ++ i) {
cin >> x >> y;
if (! f[y] || x < f[y])
f[y] = x;
}
for (auto i = f.begin (); i != f.end (); ++ i) //map 独特的遍历方式,其中 auto 可以替换为 map <int, int> :: iterator,i->first 表示第一位(下标),i->second 表示第二维(数值)
maxx = max (maxx, i->second);
cout << maxx;
return 0;
}

浙公网安备 33010602011771号