Codeforces Round #202 (Div. 2)A
来源:互联网 发布:尤克里里制谱软件 编辑:程序博客网 时间:2024/06/08 08:15
A:按给定的顺序排队买票,只有25、50、100三种面额的钱,问是否能够找零。
#include<iostream>#include<set>#include<map>#include<vector>#include<queue>#include<cmath>#include<climits>#include<cstdio>#include<string>#include<cstring>#include<algorithm>typedef long long LL;using namespace std;int n,a[100010];int b[5];int main(){ while(cin>>n) { memset(b,0,sizeof(b)); bool flag=true; for(int i=0;i<n;i++) scanf("%d",&a[i]); for(int i=0;i<n;i++) { if(a[i]==25) b[0]++; if(a[i]==50) { if(b[0]<1) { flag=false; break; } b[0]--; b[1]++; } if(a[i]==100) { if(b[1]>=1) { b[1]--; if(b[0]>=1) b[0]--; else { flag=false; break; } } else if(b[0]>=3) { b[0]-=3; } else { flag=false; break; } b[2]++; } } if(flag) cout<<"YES"<<endl; else cout<<"NO"<<endl; } return 0;}
- Codeforces Round #202 (Div. 2)A
- Codeforces Round #202 (Div. 2) A,B
- Codeforces Round #202 (Div. 2) (A、B、C、D)
- Codeforces Round #202 (Div. 2)(A)贪心
- Codeforces Round #202 (Div. 1) A. Mafia
- Codeforces Round #202 (Div. 1) A. Mafia
- Codeforces Round #131 (Div. 2) A B
- Codeforces Round #174 (Div. 2) Problem A
- Codeforces Round #173 (Div. 2) A.Bit++
- Codeforces Round #181 (Div. 2) A题
- Codeforces Round #184 (Div. 2) A题
- Codeforces Round #185 (Div. 2)--A,B
- Codeforces Round #172 (Div. 2) A题
- Codeforces Round #166 (Div. 2) A题
- Codeforces Round #132 (Div. 2) A题
- Codeforces Round #131 (Div. 2) A题
- Codeforces Round #133 (Div. 2) A题
- Codeforces Round #137 (Div. 2) A题
- Kinect for Windows SDK开发入门(四):景深数据处理 上
- 缓存
- spring+velocity+javamail发送模板邮件
- JS+html 实现select二级联动菜单
- google code 上源代码的下载方法
- Codeforces Round #202 (Div. 2)A
- Notes9.0中Typeahead 同时显示服务器和本地联系人
- (c++)图形4
- .net mail發送
- 《Java程序员上班那点事儿》自我小结2
- VS2010 C++ 操作Excel表格的编程实现
- Android ---Application 开发中共享全局数据
- 直接拿来用!10款实用Android UI工具
- Domino服务器在Outbound消息中定义发件人Internet地址的格式