-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuva11292.cpp
More file actions
43 lines (34 loc) · 732 Bytes
/
Copy pathuva11292.cpp
File metadata and controls
43 lines (34 loc) · 732 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*
* Contest : UVA
* Problem : 11292 - Dragon of Loowater
* Link : https://vjudge.net/problem/UVA-11292
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define fastio ios::sync_with_stdio(0); cin.tie(0);
void solve(int n, int m) {
vector<int> h(n), k(m);
for (auto &i : h) cin >> i;
sort(h.begin(), h.end());
for (auto &i : k) cin >> i;
sort(k.begin(), k.end());
int i = 0, j = 0, gold = 0;
while (i < n && j < m) {
if (k[j] >= h[i]) {
gold += k[j];
i++;
}
j++;
}
if (i < n) cout << "Loowater is doomed!\n";
else
cout << gold << '\n';
}
int main() {
fastio
int n, m;
queue<int> q;
while (cin >> n >> m, n && m) solve(n, m);
return 0;
}