笔者休息娱乐。
1 const int maxn = 1e5 + 5; 2 int n, m, a; 3 4 ll solve(int n, int m) { 5 ll ans = 0; 6 priority_queue<int, vector<int>, greater<int>> dragon, knight; 7 8 rep(i, 1, n) { 9 read(a); 10 dragon.push(a); 11 } 12 rep(i, 1, m) { 13 read(a); 14 knight.push(a); 15 } 16 17 if (m < n) return -1; 18 while (true) { 19 if (dragon.empty()) return ans; 20 if (knight.empty()) return -1; 21 if (dragon.top() <= knight.top()) { 22 dragon.pop(); 23 ans += knight.top(); 24 knight.pop(); 25 } else knight.pop(); 26 } 27 } 28 29 int main() { 30 while (~scanf("%d %d", &n, &m) && (n | m)) { 31 ll k = solve(n, m); 32 if (k >= 0) writeln(k); 33 else puts("Loowater is doomed!"); 34 } 35 return 0; 36 }