Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Author : pedrocas
- * Date : 2023 Sep 24 04:50:39 PM
- */
- #include <bits/stdc++.h>
- using namespace std;
- typedef long long ll;
- const long long mod = 1000000007;
- ll gcd (ll a, ll b) {return b==0 ? a : gcd(b, a%b);}
- #define all(c) (c).begin(),(c).end()
- #define pb push_back
- #define mp make_pair
- #define fastio ios_base::sync_with_stdio(false); cin.tie(nullptr);
- const int di4[] = {-1, 0, 1, 0};
- const int dj4[] = { 0, 1, 0, -1};
- const int di8[] = {-1, 0, 1, 0, -1, 1,-1,1};
- const int dj8[] = { 0, 1, 0, -1, -1, 1,1,-1};
- const int maxn = 2e5 + 10;
- const ll INF = 1e18;
- int main()
- {
- #ifdef LOCAL
- freopen("input.txt", "rt", stdin);
- freopen("output.txt", "wt", stdout);
- #endif
- fastio
- int tc = 1;
- //cin >> tc;
- while(tc-- ){
- int n;cin >> n;
- set<int> st;
- for(int i = 0, x; i<n; i++)cin >> x, st.insert(x);
- while(--n){
- string s;cin >> s;
- int c = tolower(s[s.size() - 1]) - 'a' + 1;
- int x = *st.begin(), y = *st.rbegin();
- if(abs(x - c) > abs(y - c)){
- st.erase(x);
- }else if(abs(x - c) < abs(y - c)){
- st.erase(y);
- }else{
- if(x > y){
- st.erase(y);
- }else st.erase(x);
- }
- }
- cout << *st.begin() <<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement