HDUOJ-4104 Discount
Discount
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 984 Accepted Submission(s): 591

All the shops use discount to attract customers, but some shops doesn’t give direct discount on their goods, instead, they give discount only when you bought more than a certain amount of goods. Assume a shop offers a 20% off if your bill is more than 100 yuan, and with more than 500 yuan, you can get a 40% off. After you have chosen a good of 400 yuan, the best suggestion for you is to take something else to reach 500 yuan and get the 40% off.
For the customers’ convenience, the shops often offer some low-price and useful items just for reaching such a condition. But there are still many customers complain that they can’t reach exactly the budget they want. So, the manager wants to know, with the items they offer, what is the minimum budget that cannot be reached. In addition, although the items are very useful, no one wants to buy the same thing twice.
The first line contains one integer N (1 <= N <= 1000), the number of items available.
The second line contains N integers Pi (0 <= Pi <= 10000), represent the ith item’s price.
#include<iostream>
#include<cstdio>
#include<algorithm>
#define maxn 1001
using namespace std;
int value[maxn];
int main()
{
int n,i,sum;
while(~scanf("%d",&n))
{
for(i=;i<n;i++)
scanf("%d",value+i);
sort(value,value+n);
sum=;
for(i=;i<n;i++)
{
if(sum+<value[i])
break;
sum+=value[i];
}
cout<<sum+<<endl;
}
return ;
}
要成为高手千万不要复制
HDUOJ-4104 Discount的更多相关文章
- HDU 4104 Discount(n个数不能构成的最小值)
http://acm.hdu.edu.cn/showproblem.php?pid=4104 题意:给出n个数,每个数最多只能用一次,每次可以选任意个数相加,求不能相加得到的最小值是多少. 思路: 先 ...
- hdu 4104 Discount
http://acm.hdu.edu.cn/showproblem.php?pid=4104 一开始还以为这题是背包,然后优化下这个背包,但是一直都优化不出来. 然后题解是直接模拟而已,唉 先从小到大 ...
- hduoj 1455 && uva 243 E - Sticks
http://acm.hdu.edu.cn/showproblem.php?pid=1455 http://uva.onlinejudge.org/index.php?option=com_onlin ...
- 【BZOJ 4104】【Thu Summer Camp 2015】解密运算
http://www.lydsy.com/JudgeOnline/problem.php?id=4104 网上题解满天飞,我也懒得写了 #include<cstdio> #include& ...
- hduoj 4712 Hamming Distance 2013 ACM/ICPC Asia Regional Online —— Warmup
http://acm.hdu.edu.cn/showproblem.php?pid=4712 Hamming Distance Time Limit: 6000/3000 MS (Java/Other ...
- hduoj 4706 Herding 2013 ACM/ICPC Asia Regional Online —— Warmup
hduoj 4706 Children's Day 2013 ACM/ICPC Asia Regional Online —— Warmup Herding Time Limit: 2000/1000 ...
- Discount Diesel Time 9150-1 Quartz Wrist watch [WAT022]- US$4.49
Discount Diesel Time 9150-1 Quartz Wrist watch [WAT022]- US$4.49 Diesel Time 9150-1 Quartz Wrist wat ...
- hdu-oj 1874 畅通工程续
最短路基础 这个题目hdu-oj 1874可以用来练习最短路的一些算法. Dijkstra 无优化版本 #include<cstdio> #include<iostream> ...
- C#版 - HDUoj 5391 - Zball in Tina Town(素数) - 题解
版权声明: 本文为博主Bravo Yeung(知乎UserName同名)的原创文章,欲转载请先私信获博主允许,转载时请附上网址 http://blog.csdn.net/lzuacm. HDUoj 5 ...
- C++版 - HDUoj 2010 3阶的水仙花数 - 牛客网
版权声明: 本文为博主Bravo Yeung(知乎UserName同名)的原创文章,欲转载请先私信获博主允许,转载时请附上网址 http://blog.csdn.net/lzuacm. C++版 - ...
随机推荐
- C#中的String与string
在C#中,string 是 System.String 的别名,所以基本上在使用时是没有差别的. 习惯上,我们把字符串当作对象时(有值的对象实体),我们用string. 而我们把它当类时(需要字符串类 ...
- TextView设置最多显示指定个字符,超过部分显示...(省略号)
今天在公司遇到一个需求:TextView设置最多显示8个字符,超过部分显示...(省略号),网上找了很多资料,有人说分别设置TextView的android:signature="true& ...
- Eclipse中运行Tomcat遇到的内存溢出错误
使用Eclipse(版本Indigo 3.7)调试Java项目的时候,遇到了下面的错误: Exception in thread "main" Java.lang.OutOfMem ...
- 郑捷2017年电子工业出版社出版的图书《NLP汉语自然语言处理原理与实践》
郑捷2017年电子工业出版社出版的图书<NLP汉语自然语言处理原理与实践> 第1章 中文语言的机器处理 1 1.1 历史回顾 2 1.1.1 从科幻到现实 2 1.1.2 早期的探索 3 ...
- 从win10家庭版/中文版升级到win10专业版
发布时间:2015-8-4 很多同学在不了解win10系统版本的情况下,安装了win10家庭版/中文版,不管是win10家庭版,还是win10家庭中文版,或者是win10家庭单语言版,它们都是 ...
- poj 3041 Asteroids 题解
Asteroids Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 20686 Accepted: 11239 Descr ...
- scala 学习笔记四 匿名函数
1.介绍 Scala 中定义匿名函数的语法很简单,箭头左边是参数列表,右边是函数体. 使用匿名函数后,我们的代码变得更简洁了. 下面的表达式就定义了一个接受一个Int类型输入参数的匿名函数: var ...
- Python构造字符串
不断报错 coercing to Unicode : 不要用+连接字符串,要用格式化字符串 None的问题:只能用 or “”的方式来解决了 not all arguments converted d ...
- [Backbone]2. More detail in Models
Our Appointment model doesn't seem too useful yet. Add two default attributes, title as the string & ...
- 【Nodejs】“快算24”扑克牌游戏算法 1.02
快算24是一种挺好的锻炼孩子算数能力的扑克牌游戏,它的游戏方式是把四张牌的牌面数值通过有限四则运算得到结果24,四张牌必须仅用一次.各地玩法还有点差别,有的只算1-10,其它抽出来:有的地方把整幅牌都 ...