CF731B.Coupons and Discounts
普及-
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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 a__i 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 a__i 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.
编程竞赛赛季已经拉开帷幕,是时候为 ICPC 进行训练了。Sereja 多年来一直担任各支队伍的教练,他深知:要为一次训练课做好准备,仅准备题目和题解是远远不够的。由于训练课持续数小时,队员们会感到饥饿。因此,Sereja 会提前订购若干份披萨,以便比赛一结束就能立即享用。
各支队伍计划在连续的 n 天内共进行 n 次训练。每次训练课上,Sereja 恰好为当天到场的每支队伍订购一份披萨。他已知第 i 天将有 ai 支队伍到场。
Sereja 最常光顾的披萨店提供两种折扣方式:
- 第一种折扣:若某一天内购买两份披萨,则可享受该折扣;
- 第二种折扣:一张优惠券,允许在连续两天内各购买一份披萨(总共两份)。
由于 Sereja 在该店订购披萨的数量极大,他已成为“金牌客户”,可无限制地在任意日期使用任意数量的任意类型折扣或优惠券。
Sereja 希望恰好在第 i 天订购 ai 份披萨,并且仅通过使用上述折扣与优惠券来实现。注意:他绝不会在某一天订购超过当天实际所需数量的披萨。请你帮他判断:在仅允许使用优惠券和折扣的前提下,是否可能使每天订购的披萨数量均恰好为 ai?另外请注意:在第 n 天结束后,不允许存在任何尚未使用的(即仍处于“激活”状态的)优惠券。
输入格式
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 _a_1, _a_2, ..., a__n (0 ≤ a__i ≤ 10 000) — the number of teams that will be present on each of the days.
输入的第一行包含一个整数 n(1≤n≤200000)——训练场次的数量。
第二行包含 n 个整数 a1,a2,…,an(0≤ai≤10000)——每天将到场的队伍数量。
输出格式
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).
如果存在一种仅使用优惠券和折扣来订购披萨的方法,且在任何一天都不额外购买披萨,则在输出的唯一一行中打印 "YES"(不带引号)。否则,打印 "NO"(不带引号)。
输入输出样例
输入#1
4 1 2 1 2
输出#1
YES
输入#2
3 1 0 1
输出#2
NO
说明/提示
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.
在第一个样例中,Sereja 可以使用一张优惠券在第一天和第二天各购买一份披萨,再使用一张优惠券在第二天和第三天各购买一份披萨,并使用一次折扣在第四天购买披萨。这是该样例中订购披萨的唯一方式。
在第二个样例中,Sereja 若不额外订购一份披萨,则既无法使用优惠券,也无法使用折扣。注意:某些天可能没有团队参加培训课程。
输入解题思路,AI测评打分。不知道怎么写?