func_code_string: #include <bits/stdc++.h>   using namespace std;   const long long mod = 1e9 + 7;   long long power(long long x, long long y, long long p) {     long long res = 1;     x = x % p;     while (y > 0) {       if (y & 1) res = (res * x) % p;       y = y >> 1;       x = (x * x) % p;     }     return res;   }   const long long L = 1e5 + 5;   long long arr[L];   long long bo[L];   long long gi[L];   long long bg[L];   priority_queue<long long> val;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long i, b, g;     cin >> b >> g;     long long ans = 0;     long long x = -1e18, y = 1e18;     for (i = 0; i < b; i++) {       bg[i] = 1;       cin >> bo[i];       arr[i] = g - 1;       ans += bo[i];       x = max(bo[i], x);     }     for (i = 0; i < g; i++) {       cin >> gi[i];       ans += gi[i];       val.push(gi[i]);       y = min(gi[i], y);     }     if (y < x) {       cout << -1 << endl;       return 0;     }     sort(bo, bo + b);     i = b - 1;     while (!val.empty() && i >= 0) {       if (val.top() >= bo[i]) {         if (arr[i] == 0) {           if (bo[i] == val.top()) {             ans -= bo[i];             val.pop();           }           i--;           continue;         }         arr[i]--;         val.pop();       } else         i--;     }     for (i = 0; i < b; i++) ans += arr[i] * bo[i];     cout << ans << endl;     return 0;   }   