Codeforces Round #202 (Div. 2) A,B
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 <cstdio> #include <cstring> using namespace std; int ershiwu,wushi,n,money; int main() return 0; |
* This source code was highlighted by YcdoiT. ( style: Codeblocks )
2 seconds
256 megabytes
standard input
standard output
Igor has fallen in love with Tanya. Now Igor wants to show his feelings and write a number on the fence opposite to Tanya's house. Igor thinks that the larger the number is, the more chance to win Tanya's heart he has.
Unfortunately, Igor could only get v liters of paint. He did the math and concluded that digit d requires ad liters of paint. Besides, Igor heard that Tanya doesn't like zeroes. That's why Igor won't use them in his number.
Help Igor find the maximum number he can write on the fence.
The first line contains a positive integer v (0≤v≤106). The second line contains nine positive integers a1,a2,...,a9 (1≤ai≤105).
Print the maximum number Igor can write on the fence. If he has too little paint for any digit (so, he cannot write anything), print -1.
5
5 4 3 2 1 2 3 4 5
55555
2
9 11 1 12 5 8 9 10 6
33
0
1 1 1 1 1 1 1 1 1
-1
先保证位数最大,然后使用余数尽量升级成大的数
|
#include <iostream>
#include <cstdio> #include <cstring> #include <algorithm> using namespace std; struct nim bool cmp(nim a,nim b) bool cmp2(nim a,nim b) int number[12]; int main() if(n<a[0].cost) memset(number,0,sizeof(number)); sort(a+1,a+9,cmp2); for(int i=1;i<9;i++) |
* This source code was highlighted by YcdoiT. ( style: Codeblocks )
Codeforces Round #202 (Div. 2) A,B的更多相关文章
- Codeforces Round #202 (Div. 2)
第一题水题但是wa了一发,排队记录下收到的25,50,100,看能不能找零,要注意100可以找25*3 复杂度O(n) 第二题贪心,先找出最小的花费,然后就能得出最长的位数,然后循环对每个位上的数看能 ...
- Codeforces Round #202 (Div. 1) A. Mafia 贪心
A. Mafia Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/348/problem/A D ...
- Codeforces Round #202 (Div. 1) A. Mafia 推公式 + 二分答案
http://codeforces.com/problemset/problem/348/A A. Mafia time limit per test 2 seconds memory limit p ...
- Codeforces Round #202 (Div. 1) D. Turtles DP
D. Turtles Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/547/problem/B ...
- Codeforces Round #202 (Div. 2) B,C,D,E
贪心 B. Color the Fence time limit per test 2 seconds memory limit per test 256 megabytes input standa ...
- Codeforces Round #633 (Div. 2)
Codeforces Round #633(Div.2) \(A.Filling\ Diamonds\) 答案就是构成的六边形数量+1 //#pragma GCC optimize("O3& ...
- Codeforces Round #366 (Div. 2) ABC
Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...
- Codeforces Round #354 (Div. 2) ABCD
Codeforces Round #354 (Div. 2) Problems # Name A Nicholas and Permutation standard input/out ...
- Codeforces Round #368 (Div. 2)
直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输 ...
随机推荐
- python抓取网页过程
准备过程 1.抓取网页的过程 准备好http请求(http request)->提交对应的请求->获得返回的响应(http response)->获得网页源码 2.GET还是POST ...
- SOA 和webservice 的区别
http://blog.csdn.net/bingjing12345/article/details/7575566 Web service 的具体过程 需要明确的东西 1, 服务器端 和 客户端 之 ...
- easyUI学习笔记之tab组件的鼠标事件
一.鼠标经过组件后的事件,自动打开选项卡内容 var tabs = $('#tt').tabs().tabs('tabs'); for(var i=0; i<tabs.length; i++){ ...
- 自然语言6_treebank句子解析
#英文句子结构分析 import nltkfrom nltk.corpus import treebankt = treebank.parsed_sents('wsj_0001.mrg')[1]t.d ...
- Nginx+HTTPS(SSL/TLS)
环境 首先确保机器上安装了openssl和openssl-devel rpm -qa | grep openssl #yum install openssl #yum install openssl- ...
- 使用ASP.NET Web Api构建基于REST风格的服务实战系列教程【十】——使用CacheCow和ETag缓存资源
系列导航地址http://www.cnblogs.com/fzrain/p/3490137.html 前言 本文将使用一个开源框架CacheCow来实现针对Http请求资源缓存,本文主要介绍服务器端的 ...
- macbook pro的usb串口失效的的处理方法
macbook pro的usb串口失效的的处理方法 2011-08-24 12:14:32| 分类: mac|举报|字号 订阅 今天开电脑,无端端一个usb的串口失效了,接入鼠标 iphon ...
- Ubuntu 14.04 LTS 更新源大全
Ubuntu 14.04 LTS 系统更新源汇总 如何使用这些系统更新源?---三步走 首先备份源列表: sudo cp /etc/apt/sources.list /etc/apt/sources. ...
- asp.net 中的app_offline.htm的使用
前段时间,系统升级,由于系统更新发布时间较长,所以必须停掉站点进行更新.导致很多用户都来反馈系统无法访问,还认为站点被黑掉了. 所以经过那件事我们也在思考,如何做到不停机,进行热部署.单机环境下(双机 ...
- List.Sort用法
treeList.Sort((x, y) => x.SortIndex < y.SortIndex ? -1 : 0);