Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- using namespace std;
- int main() {
- int n;
- cin >> n;
- vector<int> x1;
- vector<int> x2;
- for (int i = 0; i < n; i++) {
- int z;
- cin >> z;
- x1.push_back(z);
- cin >> z;
- x2.push_back(z);
- }
- int s1, s2;
- s1 = x1[0];
- s2 = x2[0];
- for (int i = 1; i < n; i++) {
- if (s1 < x1[i]) {
- s1 = x1[i];
- }
- if (s2 > x2[i]) {
- s2 = x2[i];
- }
- }
- if (s2 - s1 < 0) {
- cout << 0;
- }
- else cout << s2 - s1;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement