cyalue

Untitled

Jul 25th, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.69 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <utility>
  4. #include <algorithm>
  5. #include <string>
  6. #include <cctype>
  7. #include <stack>
  8. using namespace std;
  9.  
  10.  
  11.  
  12. int main() {
  13.     int n;
  14.     cin >> n;
  15.     vector<pair<int, int>> num(n);
  16.     for (int i = 0; i < n; i++) {
  17.         cin >> num[i].first >> num[i].second;
  18.     }
  19.     sort(num.begin(), num.end());
  20.     int prevf = 0;
  21.     int found = 0;
  22.     int moment = 0;
  23.     int prevm = 0;
  24.    
  25.     for (int i = 0; i < n; i++) {
  26.         moment = num[i].first;
  27.         for (int j = 0; j < n; j++) {
  28.             if (moment >= num[j].first && moment <= num[j].second) {
  29.                 found++;
  30.             }
  31.         }
  32.         if (found > prevf) {
  33.             prevf = found;
  34.             prevm = moment;
  35.         }
  36.         found = 0;
  37.     }
  38.     cout << prevm;
  39.     return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment