func_code_string: #include <bits/stdc++.h>   using namespace std;   const int maxn = 100000 + 5;   int b[maxn];   int g[maxn];   int main() {     int n, m;     scanf( %d%d , &n, &m);     for (int i = 1; i <= n; i++) scanf( %d , &b[i]);     for (int i = 1; i <= m; i++) scanf( %d , &g[i]);     long long sum = 0;     sort(b + 1, b + n + 1);     sort(g + 1, g + m + 1);     if (b[n] > g[1])       printf( -1 n );     else {       int cur = m;       for (int i = n; i >= 1; i--) {         sum += (long long)b[i] * m;         int k = m;         if (cur == m) {           while (k > 0 && cur >= 2 && g[cur] > b[i]) {             k--;             sum += g[cur] - b[i];             cur--;           }         } else {           while (k > 0 && cur >= 1 && g[cur] > b[i]) {             k--;             sum += g[cur] - b[i];             cur--;           }         }         while (cur >= 1 && g[cur] == b[i]) cur--;       }       if (cur >= 1)         printf( -1 n );       else         printf( %I64d n , sum);     }     return 0;   }   