Advertisement
MohamedAbdel3al

A. Favorite Foods

Sep 17th, 2021
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std ;
  4. #define sz(s) int(s.size())
  5. typedef long long ll ;
  6. #define all(v) v.begin() , v.end()
  7.  
  8. void ABDEL3AL () {
  9. ios_base::sync_with_stdio(false); cin.tie(nullptr) , cout.tie(nullptr) ;
  10. #ifndef ONLINE_JUDGE
  11. freopen("input.txt" , "r" , stdin) , freopen("output.txt" , "w" , stdout) ;
  12. #endif
  13. }
  14.  
  15. int main() {
  16. ABDEL3AL() ;
  17. int n ; cin >> n ;
  18. pair <string , int> fav[n] ;
  19. for (int i = 0; i < n; i++) cin >> fav[i].first >> fav[i].second ;
  20. int Min = INT_MAX , Max = INT_MIN ;
  21. string Minfav_f , Maxfav_f ;
  22. for (int i = 0; i < n; i++) {
  23. Min = min(Min , fav[i].second) , Minfav_f = fav[i].first ;
  24. Max = max(Max , fav[i].second) , Maxfav_f = fav[i].first ;
  25. }
  26. cout << Minfav_f << " " << Maxfav_f ;
  27.  
  28. return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement