func_code_string: #include <bits/stdc++.h>   using namespace std;   const int maxn = 1e5 + 10;   long long n, m;   long long a[maxn], b[maxn];   bool cmp(long long a, long long b) { return a > b; }   int main() {     scanf( %lld %lld , &n, &m);     for (int i = 1; i <= n; i++) scanf( %lld , &a[i]);     for (int i = 1; i <= m; i++) scanf( %lld , &b[i]);     sort(a + 1, a + n + 1, cmp);     sort(b + 1, b + m + 1, cmp);     if (a[1] > b[m]) {       cout << -1 << endl;       return 0;     }     long long ans = a[1], t = m - 1, bj = 1;     for (int i = 1; i <= m; i++) {       if (b[i] == a[1]) continue;       if (t == 0) {         bj++;         ans += a[bj];         t = m - 1;       }       ans += b[i];       t--;     }     for (int i = n; i > bj; i--) ans += (a[i] * m);     ans += t * a[bj];     cout << ans << endl;     return 0;   }   