zoj 1200 Mining
这道题被划到了动态规划里面去了,结果就是一道模拟题,懒了一点,直接用stl的优先队列,重载了一下运算符,写的时候保证只能一个在采,因为如果需要的采的次数比可以生产的次数少,那么生产的次数等于需要采的次数,算个小剪枝。
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<map>
#include<iostream>
#include<vector>
#include<cstring>
#include<queue>
#include<string>
using namespace std;
int s,w,c,k,m;
struct node
{
int t;
node(int a):t(a) {}
}; bool operator <(const node &t1,const node &t2)
{
return t1.t>t2.t;
}
priority_queue<node> q;
int solve()
{
while(!q.empty())
q.pop();
int ans=(10000-0.5)/c+1;
k=min(k,ans);
int f=0;
for(int i=1;i<=k;i++)
q.push(node(m*i+s));
int aa=-1;
while(!q.empty())
{
node x=q.top();
q.pop();
if(x.t<aa)
x.t=aa;
aa=x.t+w;
f++;
if(f==ans)
return x.t+w+s;
q.push(node(x.t+w+s+s));
}
} int main()
{
// freopen("input.txt","r",stdin);
while(scanf("%d%d%d%d%d",&s,&w,&c,&k,&m)==5)
{
int res=solve();
printf("%d\n",res);
}
}
再谈一下c++运算符重载,一篇博客的例子,优先队列的写法有很多,我还是习惯于结构体加单独重载函数,看起来比较清晰,好写。
zoj 1200 Mining的更多相关文章
- POJ题目细究
acm之pku题目分类 对ACM有兴趣的同学们可以看看 DP: 1011 NTA 简单题 1013 Great Equipment 简单题 102 ...
- 【转】POJ百道水题列表
以下是poj百道水题,新手可以考虑从这里刷起 搜索1002 Fire Net1004 Anagrams by Stack1005 Jugs1008 Gnome Tetravex1091 Knight ...
- ZOJ题目分类
ZOJ题目分类初学者题: 1001 1037 1048 1049 1051 1067 1115 1151 1201 1205 1216 1240 1241 1242 1251 1292 1331 13 ...
- 【转载】图论 500题——主要为hdu/poj/zoj
转自——http://blog.csdn.net/qwe20060514/article/details/8112550 =============================以下是最小生成树+并 ...
- ZOJ Monthly, March 2018 题解
[题目链接] A. ZOJ 4004 - Easy Number Game 首先肯定是选择值最小的 $2*m$ 进行操作,这些数在操作的时候每次取一个最大的和最小的相乘是最优的. #include & ...
- 正则表达式和文本挖掘(Text Mining)
在进行文本挖掘时,TSQL中的通配符(Wildchar)显得功能不足,这时,使用“CLR+正则表达式”是非常不错的选择,正则表达式看似非常复杂,但,万变不离其宗,熟练掌握正则表达式的元数据,就能熟练和 ...
- ZOJ People Counting
第十三届浙江省大学生程序设计竞赛 I 题, 一道模拟题. ZOJ 3944http://www.icpc.moe/onlinejudge/showProblem.do?problemCode=394 ...
- ZOJ 3686 A Simple Tree Problem
A Simple Tree Problem Time Limit: 3 Seconds Memory Limit: 65536 KB Given a rooted tree, each no ...
- Call for Papers IEEE/ACM International Conference on Advances in Social Network Analysis and Mining (ASONAM)
IEEE/ACM International Conference on Advances in Social Network Analysis and Mining (ASONAM) 2014 In ...
随机推荐
- oracle 经典语句集合
1.一列转多行 方法一: select a.id, substr(','||a.name||',',instr(','||a.name,',',1,b.rn)+1, instr(a.name| ...
- 自定义带弹性效果的pageControl
分三部分实现,在drawrect方法里画出灰色背景,根据pageCount创建对应个数的dotView放置在对应位置,并隐藏,创建一个CAShapeView类型的layer,根据scrollView的 ...
- 已知TSP问题的最好解
a280 : 2579ali535 : 202339att48 : 10628att532 : 27686bayg29 : 1610bays29 : 2020berlin52 : 7542bier12 ...
- 数据挖掘(data mining),机器学习(machine learning),和人工智能(AI)的区别是什么? 数据科学(data science)和商业分析(business analytics)之间有什么关系?
本来我以为不需要解释这个问题的,到底数据挖掘(data mining),机器学习(machine learning),和人工智能(AI)有什么区别,但是前几天因为有个学弟问我,我想了想发现我竟然也回答 ...
- 从一道面试题谈linux下fork的运行机制
http://www.cnblogs.com/leoo2sk/archive/2009/12/11/talk-about-fork-in-linux.html
- java.net.SocketTimeoutException: Read timed out
If you get java.net.SocketTimeoutException: Read timed out exception Try setting own timeout value w ...
- Linux下查看Web服务器当前的并发连接数和TCP连接状态
对于web服务器(Nginx.Apache等)来说,并发连接数是一个比较重要的参数,下面就通过netstat命令和awk来查看web服务器的并发连接数以及TCP连接状态. $ netstat -n | ...
- UESTC_贪吃蛇 CDOJ 709
相信大家都玩过贪吃蛇游戏吧. 在n×m的迷宫中,有着一条长度不超过9的贪吃蛇,它已经将所有的食物吃光了,现在的目标是移动到出口. 它走的时候不能碰到自己的身体,也不能碰到墙壁.(如果贪吃蛇的长度> ...
- Family Tree
Question A traditional constructing tree problem. Given a string to represent relationships, and pri ...
- Implement Queue using Stacks 解答
Question Implement the following operations of a queue using stacks. push(x) -- Push element x to th ...