30 lines
649 B
C++
30 lines
649 B
C++
/*
|
|
* 特别处理有一个杆子超级长?
|
|
*/
|
|
|
|
#include <algorithm>
|
|
#include <iostream>
|
|
#include <vector>
|
|
|
|
int main() {
|
|
std::ios::sync_with_stdio(false);
|
|
std::cin.tie(nullptr);
|
|
|
|
int n;
|
|
std::cin >> n;
|
|
|
|
std::vector<int> half_lengths;
|
|
half_lengths.reserve(2 * n);
|
|
for (int i = 0; i < n; i++) {
|
|
int length, flag_pos;
|
|
std::cin >> length >> flag_pos;
|
|
half_lengths.push_back(length - flag_pos);
|
|
half_lengths.push_back(flag_pos);
|
|
}
|
|
std::sort(half_lengths.begin(), half_lengths.end(), std::greater<>());
|
|
|
|
std::cout << half_lengths[0] + half_lengths[1] << std::endl;
|
|
|
|
return 0;
|
|
}
|