Magic Stones(思维题)

Magic Stones(思维题)

 

 

#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;
}

 

上一篇:C++读mnist数据


下一篇:Java学习之while循环及案例