Advertisement
Guest User

Untitled

a guest
Mar 28th, 2020
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int T, n, m, x;
  4. int main()
  5. {
  6. ios_base::sync_with_stdio(0);
  7. cin.tie(0);
  8. cout.tie(0);
  9. cin >> T;
  10. while(T--)
  11. {
  12. cin >> n >> m;
  13. int s = 0, s1 = 0;
  14. for(int i=1; i<=n; i++)
  15. {
  16. cin >> x;
  17. s+=x;
  18. }
  19. for(int i=1; i<=m; i++)
  20. {
  21. cin >> x;
  22. s1+=x;
  23. }
  24. cout << min(s, min(s1, n*m)) << '\n';
  25. }
  26. return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement