Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- #include <vector>
- #include <algorithm>
- using namespace std;
- int main() {
- ifstream cin("input.txt");
- ofstream cout("output.txt");
- int n;
- cin >> n;
- int a[n], b[n];
- for (int i = 0; i < n; i++) {
- cin >> a[i];
- }
- for (int i = 0; i < n; i++) {
- cin >> b[i];
- }
- int diff = b[0] - a[0];
- bool good = true;
- for (int i = 0; i < n; i++) {
- if (a[i] + diff != b[i]) {
- good = false;
- break;
- }
- }
- if (good)
- cout << "YES\n" << diff << '\n';
- else
- cout << "NO\n";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement