Advertisement
Guest User

Untitled

a guest
Feb 18th, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.60 KB | None | 0 0
  1. #include <fstream>
  2. #include <vector>
  3. #include <algorithm>
  4.  
  5.  
  6.  
  7. using namespace std;
  8.  
  9. int main() {
  10.     ifstream cin("input.txt");
  11.     ofstream cout("output.txt");
  12.     int n;
  13.     cin >> n;
  14.     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.     int diff = b[0] - a[0];
  22.     bool good = true;
  23.     for (int i = 0; i < n; i++) {
  24.         if (a[i] + diff != b[i]) {
  25.             good = false;
  26.             break;
  27.         }
  28.     }
  29.     if (good)
  30.         cout << "YES\n" << diff << '\n';
  31.     else
  32.         cout << "NO\n";
  33.     return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement