AcWing 4619. 减法操作
原题链接
中等
作者:
Coinisi.
,
2023-01-21 09:00:09
,
所有人可见
,
阅读 125
#include <iostream>
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
const int N = 2e5+10;
int a[N];
using namespace std;
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int n; cin >> n;
for(int i = 1; i <= n; i ++) cin >> a[i];
a[1] = a[1] % 2;
for(int i = 2; i <= n; i ++)
{
if(a[i] < a[i - 1]) {NO; return 0;}
a[i] = a[i] - a[i - 1], a[i] = a[i] % 2;
}
if(a[n]) NO;
else YES;
return 0;
}