func_code_string: #include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cout.tie(NULL);     cin.tie(NULL);     ;     int n, m;     cin >> n >> m;     set<long long> s;     long long ans = 0;     long long a[n];     long long b[m];     long long mx = 0;     map<long long, long long> mp;     bool f = true;     set<long long> st;     for (int i = 0; i < n; i++) {       cin >> a[i];       mx = max(mx, a[i]);       s.insert(a[i]);       ans += m * a[i];       st.insert(a[i]);       mp[a[i]] += m - 1;     }     for (int i = 0; i < m; i++) {       cin >> b[i];       if (b[i] < mx) f = false;     }     if (!f) {       cout << -1 << endl;       return 0;     }     sort(b, b + m);     reverse(b, b + m);     for (int i = 0; i < m; i++) {       set<long long>::iterator it = s.upper_bound(b[i]);       --it;       if ((b[i] - *it) > 0 && st.find(b[i]) != st.end()) {         continue;       }       ans += b[i] - (*it);       mp[*it]--;       if (mp[*it] == 0) s.erase(it);     }     cout << ans << endl;     return 0;   }   