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 ...
随机推荐
- iOS archive(归档)的总结
http://www.cnblogs.com/ios8/p/ios-archive.html
- 我的第一个QML Button的实现
编写第一个QML,在成功跑完HelloWorld后,决定自己实现Button按钮类. Button是在Quick2版本以上的QtQuick Controls出现的. 在Qt5.5.1版本中,选择插入Q ...
- js数组小结
1.js数组使用sort()排序 var a = ["1","12","3","4","0"]; d ...
- ZendFramework 两种安装方式
1. 在线安装(基于composer) Zend 应用程序骨架 GitHub 地址: https://github.com/zendframework/ZendSkeletonApplication ...
- poj 3318 Matrix Multiplication
http://poj.org/problem?id=3318 矩阵A*矩阵B是否等于矩阵C #include <cstdio> #include <cstring> #incl ...
- C# dynamic类型
dynamic类型是C#4.0中引入的新类型,它允许其操作掠过编译器类型检查,而在运行时处理.dynami类型在绝大多数情况下和object类型相似,不同之处在于编译器对于包含了dynamic的表达式 ...
- j2ee概览
J2EE诞生的背景是什么?Java 2平台企业版,也就是J2EE,定义了开发多层企业应用程序的标准.它的诞生并不是偶然的,它是在各种条件积累成熟之下的产物.原因之一:java语言的巨大成功.1994年 ...
- [Leetcode][Python]55: Jump Game
# -*- coding: utf8 -*-'''__author__ = 'dabay.wang@gmail.com' 55: Jump Gamehttps://leetcode.com/probl ...
- 哥德尔,图灵和康托尔 part 1 哥德尔编号
在看计算理论相关的书的时候,偶然看到这个blog,http://skibinsky.com/godel-turing-and-cantor-the-math/,写的很好.我觉得用自动机的方式讲计算理论 ...
- Linux开机禁用开启防火墙
1.# chkconfig --list:显示开机可以自动启动的服务 结果:iptables 0:off 1:off 2:on 3:on 4:on 5:on ...