Advertisement
pedrocasdev

Untitled

Sep 24th, 2023
876
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.22 KB | None | 0 0
  1. /*
  2.  * Author : pedrocas
  3.  * Date   : 2023 Sep 24 04:50:39 PM
  4. */
  5.  
  6. #include <bits/stdc++.h>
  7.  
  8. using namespace std;
  9.  
  10. typedef long long ll;
  11. const long long mod = 1000000007;
  12. ll gcd (ll a, ll b) {return b==0 ? a : gcd(b, a%b);}
  13.  
  14. #define all(c) (c).begin(),(c).end()
  15. #define pb push_back
  16. #define mp make_pair
  17. #define fastio ios_base::sync_with_stdio(false); cin.tie(nullptr);
  18.  
  19. const int di4[] = {-1, 0, 1,  0};
  20. const int dj4[] = { 0, 1, 0, -1};
  21. const int di8[] = {-1, 0, 1,  0, -1, 1,-1,1};
  22. const int dj8[] = { 0, 1, 0, -1, -1, 1,1,-1};
  23.  
  24. const int maxn = 2e5 + 10;
  25. const ll INF = 1e18;
  26.  
  27. int main()
  28. {
  29. #ifdef LOCAL
  30.     freopen("input.txt", "rt", stdin);
  31.     freopen("output.txt", "wt", stdout);
  32. #endif
  33.     fastio
  34.     int tc = 1;
  35.     //cin >> tc;
  36.     while(tc-- ){
  37.         int n;cin >> n;
  38.         set<int> st;
  39.         for(int i = 0, x; i<n; i++)cin >> x, st.insert(x);
  40.         while(--n){
  41.             string s;cin >> s;
  42.             int c = tolower(s[s.size() - 1]) - 'a' + 1;
  43.             int x = *st.begin(), y = *st.rbegin();
  44.             if(abs(x - c) > abs(y - c)){
  45.                 st.erase(x);   
  46.             }else if(abs(x - c) < abs(y - c)){
  47.                 st.erase(y);   
  48.             }else{
  49.                 if(x > y){
  50.                     st.erase(y);
  51.                 }else st.erase(x);
  52.  
  53.             }
  54.         }
  55.         cout << *st.begin() <<endl;
  56.  
  57.     }
  58.     return 0;
  59. }
  60.  
  61.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement