A. Cinema Line
2 seconds
256 megabytes
standard input
standard output
The new "Die Hard" movie has just been released! There are n people at the cinema box office standing in a huge line. Each of them has a single 100, 50 or 25 ruble bill. A "Die Hard" ticket costs 25 rubles. Can the booking clerk sell a ticket to each person and give the change if he initially has no money and sells the tickets strictly in the order people follow in the line?
The first line contains integer n (1 ≤ n ≤ 105) — the number of people in the line. The next line contains n integers, each of them equals 25, 50 or 100 — the values of the bills the people have. The numbers are given in the order from the beginning of the line (at the box office) to the end of the line.
Print "YES" (without the quotes) if the booking clerk can sell a ticket to each person and give the change. Otherwise print "NO".
4
25 25 50 50
YES
2
25 100
NO
4
50 50 25 25
NO
#include<iostream>
#include<string.h>
using namespace std;
int main()
{
int n,a[];
cin>>n;
for(int i=;i<n;i++)
{
cin>>a[i];
}
int t1=,t2=,flag=;
for(int i=;i<n;i++)
{
if(a[i]==)
{
t1++;
continue;
}
if(a[i]==)
{
if(t1>=)
{
t2++;
t1--;
continue;
}
else
{
flag=;
break;
}
}
if(a[i]==)
{
if(t1>=&&t2>=)
{
t1--;
t2--;
continue;
}
if(t1>=)
{
t1=t1-;
continue;
} else
{
flag=;
break;
}
} }
if(flag==)
cout<<"YES"<<endl;
else
cout<<"NO"<<endl;
return ;
}
A. Cinema Line的更多相关文章
- codeforces A. Cinema Line 解题报告
题目链接:http://codeforces.com/problemset/problem/349/A 题目意思:题目不难理解,从一开始什么钱都没有的情况下,要向每一个人售票,每张票价格是25卢布,这 ...
- Codeforces Round #202 (Div. 2) A,B
A. Cinema Line time limit per test 2 seconds memory limit per test 256 megabytes input standard inpu ...
- http://codeforces.com/contest/349
A. Cinema Line time limit per test 2 seconds memory limit per test 256 megabytes input standard inpu ...
- ACM团队周赛题解(1)
这次周赛题目拉了CF315和CF349两套题. 因为我代码模板较长,便只放出关键代码部分 #define ll long long #define MMT(s,a) memset(s, a, size ...
- 【Codeforces 738C】Road to Cinema
http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...
- Codeforces #380 div2 C(729C) Road to Cinema
C. Road to Cinema time limit per test 1 second memory limit per test 256 megabytes input standard in ...
- Codeforces Round #380 (Div. 2, Rated, Based on Technocup 2017 - Elimination Round 2)C. Road to Cinema 二分
C. Road to Cinema time limit per test 1 second memory limit per test 256 megabytes input standard in ...
- cf380D Sereja and Cinema 组合数学
time limit per test 1 second memory limit per test 256 megabytes input standard input outp ...
- ZOJ 3635 Cinema in Akiba(线段树)
Cinema in Akiba (CIA) is a small but very popular cinema in Akihabara. Every night the cinema is ful ...
随机推荐
- 为SSRS配置SMTP服务器身份验证
此处设置外邮地址却无法填写邮箱密码 一.安装SMTP服务 1.在服务管理器中单击“功能” 2.单击“添加功能”打开“添加功能向导”对话框 3.在“选择功能”页上选择“SMTP服务器”并选择“添加必须的 ...
- go install 命令
go install 命令简介 用于编译并安装代码包或源代码文件 安装代码包会在当前工作区的 'pkg/<平台相关目录>'下生成'归档文件' 安装命令源码文件会在当前工作区的'bin'目录 ...
- C++输出斐波那契数列的几种方法
定义: 斐波那契数列指的是这样一个数列:0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, ... 这个数列从第三项开始,每一项都等于前两项之和. 以输出斐波那 ...
- RTX这种东西究竟有什么价值?
我在第一家公司工作的时候,同事沟通用的就是RTX,第一感觉就是这么简单的软件也能卖钱? 这种东西有啥价值啊?不就是个没广告蓝色UI的qq吗? 还是那句话,当你已经习惯了一个东西之后,你不会感觉到他的价 ...
- OpenGL编程
一.简介 OpenGL™ 是行业领域中最为广泛接纳的 2D/3D 图形 API, 其自诞生至今已催生了各种计算机平台及设备上的数千优秀应用程序.OpenGL™ 是独立于视窗操作系统或其它操作系统的,亦 ...
- zookeeper集群安装(转)
转载地址:http://www.blogjava.net/hello-yun/archive/2012/05/03/377250.html 本方法,本人亲自试验,可以成功. ZooKeeper是一个分 ...
- sql语句增加字段 索引
alter table order_info add area varchar(50) create index group_compar on ry_order (group_compar); ...
- Oauth Client Credentials Grant
http://www.cnblogs.com/dudu/p/4569857.html OAuth真是一个复杂的东东,即使你把OAuth规范倒背如流,在具体实现时也会无从下手.因此,Microsoft. ...
- Java命令之javap初探
javap是jdk自带的一个工具在jdk安装目录的/bin下面可以找到,可以对代码反编译,也可以查看java编译器生成的字节码,对代码的执行过程进行分析,了解jvm内部的工作. 下面列举javap命令 ...
- mongoDB(1) -- 安装及开始
安装完成后在/bin文件夹下打开命令窗口 输入.\mongo启动数据库,若正常启动说明安装成功: 为了启动mongodb方便,将mongod.exe路径加入环境变量,电脑->属性->高级系 ...