Advertisement
Josif_tepe

Untitled

Jan 14th, 2024
496
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.71 KB | None | 0 0
  1. #include <iostream>
  2. //#include <bits/stdc++.h>
  3. #include <vector>
  4. #include <algorithm>
  5. using namespace std;
  6.  
  7.  
  8. int main()
  9. {
  10.     int n;
  11.     cin >> n;
  12.    
  13.     vector<pair<int, string> > v;
  14.    
  15.     for(int i = 0; i < n; i++) {
  16.         int x;
  17.         cin >> x;
  18.         string s;
  19.         cin >> s;
  20.         v.push_back(make_pair(x, s));
  21.     }
  22.     sort(v.begin(), v.end());
  23.     int posledno_ne = 0, prvo_da = -1;
  24.     for(int i = 0; i < v.size(); i++) {
  25.         if(v[i].second == "NE") {
  26.             posledno_ne = v[i].first;
  27.         }
  28.         else {
  29.             prvo_da = v[i].first;
  30.             break;
  31.         }
  32.     }
  33.     cout << posledno_ne + 1 << " " << prvo_da - 1 << endl;
  34.     return 0;
  35. }
  36.  
  37.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement