Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <utility>
- #include <algorithm>
- #include <string>
- #include <cctype>
- #include <stack>
- using namespace std;
- int main() {
- int n;
- cin >> n;
- vector<pair<int, int>> num(n);
- for (int i = 0; i < n; i++) {
- cin >> num[i].first >> num[i].second;
- }
- sort(num.begin(), num.end());
- int prevf = 0;
- int found = 0;
- int moment = 0;
- int prevm = 0;
- for (int i = 0; i < n; i++) {
- moment = num[i].first;
- for (int j = 0; j < n; j++) {
- if (moment >= num[j].first && moment <= num[j].second) {
- found++;
- }
- }
- if (found > prevf) {
- prevf = found;
- prevm = moment;
- }
- found = 0;
- }
- cout << prevm;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment