func_code_string: #include <bits/stdc++.h>   using namespace std;   const int dx[] = {-1, 0, 1, 0};   const int dy[] = {0, -1, 0, 1};   inline int read() {     int ans = 0;     bool f = 1;     char ch = getchar();     while (!isdigit(ch)) f ^= ch ==  - , ch = getchar();     while (isdigit(ch)) ans = ((ans << 2) + ans << 1) + (ch ^ 48), ch = getchar();     return f ? ans : -ans;   }   int n, m;   long long b[100010], g[100010];   long long ans;   int main(int argc, char const *argv[]) {     ios::sync_with_stdio(false);     scanf( %d%d , &n, &m);     for (int i = 1; i <= n; i++) scanf( %I64d , &b[i]);     for (int i = 1; i <= m; i++) scanf( %I64d , &g[i]);     sort(b + 1, b + n + 1);     sort(g + 1, g + m + 1);     if (b[n] > g[1])       cout << -1;     else if (b[n] == g[1]) {       for (int i = 1; i < n; i++) ans += b[i] * m;       for (int i = 1; i <= m; i++) ans += g[i];       cout << ans;     } else {       ans += b[n] + g[1] + b[n - 1] * (m - 1);       for (int i = n - 2; i >= 1; i--) ans += b[i] * m;       for (int i = 2; i <= m; i++) ans += g[i];       cout << ans;     }     return 0;   }   