#include <bits/stdc++.h> using namespace std; typedef long long ll; int v1[100001]; int v2[100001]; int s1[100001]; int s2[100001]; int main () { ios::sync_with_stdio(false); int n; cin >> n; for (int i = 0; i < n; ++i) { cin >> v1[i]; } for (int i = 0; i < n; ++i) { cin >> s1[i]; } if(v1[0] != s1[0] || v1[n - 1] != s1[n - 1]) { cout << "No" << endl; return 0; } for (int i = 1; i < n; ++i) { v2[i - 1] = v1[i] - v1[i - 1]; s2[i - 1] = s1[i] - s1[i - 1]; } sort(v2, v2 + n); sort(s2, s2 + n); for (int i = 0; i < n - 1; ++i) { if (v2[i] != s2[i]) { cout << "No" << endl; return 0; } } cout << "Yes" << endl; }
原文地址:https://www.cnblogs.com/lightac/p/11437997.html
时间: 2024-11-13 01:27:25