fork download
  1. #include <iostream>
  2. #include <vector>
  3. #include <map>
  4. #include <algorithm>
  5. #include <set>
  6. using namespace std;
  7.  
  8. int main() {
  9. int t;
  10. cin >> t;
  11. while(t--){
  12. int n, x = 0, y = 1e9, num = 0;
  13. cin >> n;
  14. vector<int> a(n), b(n);
  15. for(int i = 0; i < n; i++){
  16. cin >> a[i];
  17. }
  18. for(int i = 0; i < n; i++){
  19. cin >> b[i];
  20. }
  21. for(int i = 0; i < n; i++){
  22. int m = a[i] - b[i];
  23. if(m < 0){
  24. num ++;
  25. x -= m;
  26. }
  27. else{
  28. y = min(y, m);
  29. }
  30. }
  31. cout << x << " " << y << " " << num;
  32. if(x <= y && num < 2)cout << "YES\n";
  33. else cout << "NO\n";
  34. }
  35. }
Success #stdin #stdout 0.01s 5272KB
stdin
3
4
0 5 5 1
1 4 4 0
3
1 1 3
2 2 1
2
1 10
3 3
stdout
1 1 1YES
2 2 2NO
2 7 1YES