ZOJ 1012 Mainframe
题目大意:有一台主机,有m个cpu和n的内存,有l个任务,每个任务需消耗一定的cpu和内存,给出任务的开始时间和截止时间,完成任务可获得一定的金钱,同时提前完成有奖金,延后完成要扣钱。计算到某个时间所得收入。
首先按照任务的开始时间和价值进行排序,然后就是模拟题目描述的过程了。
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
#define MAXN 10000+10 struct Job
{
int a, b;
int t, u;
int v, w, x;
bool operator < (const Job& x) const
{
if (t != x.t) return t < x.t;
else return v > x.v;
}
};
Job jobs[MAXN];
bool finish[MAXN]; int main()
{
#ifdef LOCAL
freopen("in", "r", stdin);
#endif
int F, M, N, L;
int kase = ;
while (scanf("%d", &F) != EOF && F)
{
scanf("%d%d%d", &M, &N, &L);
for (int i = ; i < L; i++)
scanf("%d%d%d%d%d%d%d", &jobs[i].a, &jobs[i].b, &jobs[i].t, &jobs[i].u, &jobs[i].v, &jobs[i].w, &jobs[i].x);
sort(jobs, jobs+L);
memset(finish, , sizeof(finish));
int income = ;
for (int i = ; i < F; i++)
{
int cpu = M, mem = N;
for (int j = ; j < L; j++)
{
if (jobs[j].t > i) break;
if (!finish[j] && cpu >= jobs[j].a && mem >= jobs[j].b)
{
cpu -= jobs[j].a;
mem -= jobs[j].b;
finish[j] = true;
income += jobs[j].v;
int t = i + ; // the finished time
if (t < jobs[j].u) income += jobs[j].w * (jobs[j].u-t);
if (t > jobs[j].u) income -= jobs[j].x * (t-jobs[j].u);
}
}
}
for (int i = ; i < L; i++)
if (!finish[i] && jobs[i].u <= F)
income -= jobs[i].x * (F - jobs[i].u);
printf("Case %d: %d\n\n", ++kase, income);
}
return ;
}
ZOJ 1012 Mainframe的更多相关文章
- 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 =============================以下是最小生成树+并 ...
- HDU 4430 & ZOJ 3665 Yukari's Birthday(二分法+枚举)
主题链接: HDU:pid=4430" target="_blank">http://acm.hdu.edu.cn/showproblem.php?pid=4430 ...
- 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 ...
- ZOJ Problem Set - 1394 Polar Explorer
这道题目还是简单的,但是自己WA了好几次,总结下: 1.对输入的总结,加上上次ZOJ Problem Set - 1334 Basically Speaking ac代码及总结这道题目的总结 题目要求 ...
- ZOJ Problem Set - 1392 The Hardest Problem Ever
放了一个长长的暑假,可能是这辈子最后一个这么长的暑假了吧,呵呵...今天来实验室了,先找了zoj上面简单的题目练练手直接贴代码了,不解释,就是一道简单的密文转换问题: #include <std ...
随机推荐
- sphinx query multiple indexes in php
http://stackoverflow.com/questions/17494784/searching-a-particular-index-using-sphinx-from-multiple- ...
- shell执行php文件传递参数
php -f index.php hello test 2314 shell命令执行php文件不像http那样通过GET方式传参 同样php文件获取的时候也不能用$_GET方法了 而是通过$argv[ ...
- io scheduler
http://doctorlzr1988.blog.163.com/blog/static/50456520201051905236683/
- zf-关于差旅报销的excel表单填写
日期一定要填,还有二级科目事由跟申请金额,如果申请金额为0的话,那么久直接删除哪一行,因为如果不删除的话,Excel表单将提交出错.
- 转 OGG add trandata 到底做了什么
有的时候我们做OGG的时候add trandata会出现异常. 这里就剖析一下add trandata到底做了什么 GGSCI (yjfora81 as ggs_admin@testdb) 2> ...
- Java之Property类使用
http://blog.csdn.net/hopestar2/article/details/6372883 在项目中经常用到各种配置文件,有.properties的,也有.xml格式的 都可以通过j ...
- base库插件---form
$().extend('serialize', function () { for (var i = 0; i < this.elements.length; i ++) { var form ...
- Linux的iptables常用配置范例(2)
iptables -F #清除所有规则 iptables -X #清除所有自定义规则 iptables -Z #各项计数归零 iptables -P INPUT DROP #将input链 ...
- 数据恢复软件Extundelete
数据恢复软件Extundelete介绍 一.概述 作为一名运维人员,保证数据的安全是根本职责,所以在维护系统的时候,要慎重和细心,但是有时也难免发生出现数据被误删除的情况,这个时候该如何快速.有效地恢 ...
- Win7下 IIS+PHP(ZendLoader)+MySQL
这里使用的是傻瓜式安装方式 下载php-5.3.18-nts-Win32-VC9-x86.msi,Win7下可执行文件.(下载地址 http://pan.baidu.com/s/1qvJCA) 执行到 ...