Advertisement
Josif_tepe

Untitled

Jun 26th, 2024
511
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.53 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.   int n;
  7.   cin >> n;
  8.  
  9.   int niza[n];
  10.   string niza2[n];
  11.   for(int i = 0; i < n; i++) {
  12.     cin >> niza[i];
  13.     cin >> niza2[i];
  14.   }
  15.  
  16.   int najmal = 2e9, najgolem = -2e9;
  17.   for(int i = 0; i < n; i++) {
  18.     if(niza2[i] == "DA") {
  19.       if(niza[i] < najmal) {
  20.         najmal = niza[i];
  21.       }
  22.     }
  23.     else {
  24.       if(niza[i] > najgolem) {
  25.         najgolem = niza[i];
  26.       }
  27.     }
  28.   }
  29.   cout << najgolem + 1 << " " << najmal - 1 << endl;
  30.  
  31.   return 0;
  32. }
  33.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement