Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int T, n, m, x;
- int main()
- {
- ios_base::sync_with_stdio(0);
- cin.tie(0);
- cout.tie(0);
- cin >> T;
- while(T--)
- {
- cin >> n >> m;
- int s = 0, s1 = 0;
- for(int i=1; i<=n; i++)
- {
- cin >> x;
- s+=x;
- }
- for(int i=1; i<=m; i++)
- {
- cin >> x;
- s1+=x;
- }
- cout << min(s, min(s1, n*m)) << '\n';
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement