#include<iostream>
#include<unordered_map>
#include<cstdio>
#include<algorithm>
#define count Count
#define int long long
#define P pair<int,int>
using namespace std;
P c[200000];
int count[2];
int n[2];
signed main() {
int a, b; scanf("%lld%lld", &a, &b);
n[0] = a; n[1] = b;
for (int d = 0; d < a; d++) {
int e; scanf("%lld", &e);
c[d] = { e,0 };
}
for (int d = 0; d < b; d++) {
int e; scanf("%lld", &e);
c[a+d] = { e,1 };
}
sort(c, c + a + b);
int ans = 0;
for (int i = 0; i < a+b; i++) {
ans += (int)(c[i].first)*(n[(c[i].second + 1) & 1]- count[(c[i].second + 1) & 1]+1);
count[c[i].second]++;
}
printf("%lld\n", ans);
}
./Main.cpp: In function ‘int main()’:
./Main.cpp:14:37: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
int a, b; scanf("%lld%lld", &a, &b);
^
./Main.cpp:17:27: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
int e; scanf("%lld", &e);
^
./Main.cpp:21:27: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
int e; scanf("%lld", &e);
^