B. Coupons and Discounts
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

The programming competition season has already started and it's time to train for ICPC. Sereja coaches his teams for a number of year and he knows that to get ready for the training session it's not enough to prepare only problems and editorial. As the training sessions lasts for several hours, teams become hungry. Thus, Sereja orders a number of pizzas so they can eat right after the end of the competition.

Teams plan to train for n times during n consecutive days. During the training session Sereja orders exactly one pizza for each team that is present this day. He already knows that there will be ai teams on the i-th day.

There are two types of discounts in Sereja's favourite pizzeria. The first discount works if one buys two pizzas at one day, while the second is a coupon that allows to buy one pizza during two consecutive days (two pizzas in total).

As Sereja orders really a lot of pizza at this place, he is the golden client and can use the unlimited number of discounts and coupons of any type at any days.

Sereja wants to order exactly ai pizzas on the i-th day while using only discounts and coupons. Note, that he will never buy more pizzas than he need for this particular day. Help him determine, whether he can buy the proper amount of pizzas each day if he is allowed to use only coupons and discounts. Note, that it's also prohibited to have any active coupons after the end of the day n.

Input

The first line of input contains a single integer n (1 ≤ n ≤ 200 000) — the number of training sessions.

The second line contains n integers a1, a2, ..., an (0 ≤ ai ≤ 10 000) — the number of teams that will be present on each of the days.

Output

If there is a way to order pizzas using only coupons and discounts and do not buy any extra pizzas on any of the days, then print "YES" (without quotes) in the only line of output. Otherwise, print "NO" (without quotes).

Examples
Input
4
1 2 1 2
Output
YES
Input
3
1 0 1
Output
NO
Note

In the first sample, Sereja can use one coupon to buy one pizza on the first and the second days, one coupon to buy pizza on the second and the third days and one discount to buy pizzas on the fourth days. This is the only way to order pizzas for this sample.

In the second sample, Sereja can't use neither the coupon nor the discount without ordering an extra pizza. Note, that it's possible that there will be no teams attending the training sessions on some days.

/*
ACM训练队要训练n天,第i天有ai个队训练,每个队伍需要一张披萨,教练去买披萨。有两种优惠券第一种是一次买两张,另一种是第一天买一张,
第二天必须买一张。优惠券无限多,问教练能不能用优惠券买全部的披萨,每天买的披萨不会超过需求,且优惠券不能浪费。 贪心:贪心的原则就是尽量不使第二天的数量受影响,就是第一天的能用没两张披萨的优惠圈就用这个,实在不行才用买一张的。
*/
#include<iostream>
#include<string.h>
#include<string>
#include<algorithm>
#include<stdio.h>
#include<vector>
#include<map>
#include<set>
#define N 200010
using namespace std;
int main()
{
//freopen("C:\\Users\\acer\\Desktop\\in.txt","r",stdin);
int n,a[N];
scanf("%d",&n);
for(int i=;i<=n;i++)
{
scanf("%d",&a[i]);
}
int f=;
for(int i=;i<n;i++)
{
if(a[i]%)//奇数个
{
if(!a[i+])
{
f=;
break;
}
a[i+]--;
}
}
if(f)
{
puts("NO");
return ;
}
if(a[n]%==)
puts("YES");
else
puts("NO");
return ;
}

Codeforces 376B. Coupons and Discounts的更多相关文章

  1. Codeforces 731B Coupons and Discounts(贪心)

    题目链接 Coupons and Discounts 逐步贪心即可. 若当前位为奇数则当前位的下一位减一,否则不动. #include <bits/stdc++.h> using name ...

  2. CodeForces 731B Coupons and Discounts (水题模拟)

    题意:有n个队参加CCPC,然后有两种优惠方式,一种是一天买再次,一种是买两天,现在让你判断能不能找到一种方式,使得优惠不剩余. 析:直接模拟,如果本次是奇数,那么就得用第二种,作一个标记,再去计算下 ...

  3. 【50.49%】【codeforces 731B】Coupons and Discounts

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  4. Coupons and Discounts

    Coupons and Discounts time limit per test 1 second memory limit per test 256 megabytes input standar ...

  5. 【Codeforces】Round #376 (Div. 2)

    http://codeforces.com/contest/731 不发题面了,自己点链接 总结一下 考场上 原以为这次要加很多raiting... 但FST狗记邓,只加了58rating 总结一下 ...

  6. Codeforces Round #376 (Div. 2) A B C 水 模拟 并查集

    A. Night at the Museum time limit per test 1 second memory limit per test 256 megabytes input standa ...

  7. 【codeforces 754D】Fedor and coupons

    time limit per test4 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  8. codeforces 754D. Fedor and coupons

    D. Fedor and coupons time limit per test 4 seconds memory limit per test 256 megabytes input standar ...

  9. Codeforces 161 B. Discounts (贪心)

    题目链接:http://codeforces.com/contest/161/problem/B 题意: 有n个商品和k辆购物车,给出每个商品的价钱c和类别t(1表示凳子,2表示铅笔),如果一辆购物车 ...

随机推荐

  1. day14<常见对象+>

    常见对象(正则表达式的概述和简单使用) 常见对象(字符类演示) 常见对象(预定义字符类演示) 常见对象(数量词) 常见对象(正则表达式的分割功能) 常见对象(把给定字符串中的数字排序) 常见对象(正则 ...

  2. Postman 串行传参和动态传参详解

    Postman是一款功能强大的网页调试与发送网页HTTP请求的Chrome插件 用Postman做接口测试的时候,要把多条用例一起执行,就需要把用例连接起来,一次性执行 目录 串行传参 动态传参 使用 ...

  3. 【转】Mapreduce部署与第三方依赖包管理

    Mapreduce部署是总会涉及到第三方包依赖问题,这些第三方包配置的方式不同,会对mapreduce的部署便捷性有一些影响,有时候还会导致脚本出错.本文介绍几种常用的配置方式: 1. HADOOP_ ...

  4. Hive内置数据类型

    Hive的内置数据类型可以分为两大类:(1).基础数据类型:(2).复杂数据类型.其中,基础数据类型包括:TINYINT,SMALLINT,INT,BIGINT,BOOLEAN,FLOAT,DOUBL ...

  5. struts2的防止表单重复提交

    防止表单重复提交其实就是struts2的一个拦截器的使用: struts.xml配置文件: <?xml version="1.0" encoding="UTF-8& ...

  6. CSS3D模型

    html部分 <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> < ...

  7. 移动端效果之Swiper

    写在前面 最近在做移动端方面运用到了饿了么的vue前端组件库,因为不想单纯用组件而使用它,故想深入了解一下实现原理.后续将会继续研究一下其他的组件实现原理,有兴趣的可以关注下. 代码在这里:戳我 1. ...

  8. html5获取用户当前的地理位置,即经纬度。

    $("document").ready(function(){ getMap(); }); function getMap(){ // 百度地图API功能 var map = ne ...

  9. 将 Intent 序列化,像 Uri 一样传递 Intent!!!

    一.真的需要new一个Intent吗? 在 Android 中,打开一个 Activity ,有多少种方式?不过不管是使用什么方式,最终都没办法逃避创建一个 Intent ,然后startActivi ...

  10. c# 【MVC】WebApi开发实例

    using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using S ...