Advertisement
Guest User

Untitled

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