BZOJ1569: [JSOI2008]Blue Mary的职员分配(dp 暴力)
Time Limit: 15 Sec Memory Limit: 162 MB
Submit: 483 Solved: 189
[Submit][Status][Discuss]
Description
Input
Output
Sample Input
Sample Output
HINT
1<=n,x,y,z,A,B<=20
Source
好迷的一道题啊。。刚开始想的是二分+dp瞎搞,应该能过
但是std真的好暴力骚啊
$f[i][a][b][sta]$表示此时已经有了$i$个人,$a$点金钱,$b$点声誉,里上一次打广告过去了$sta$天
转移的时候枚举一下当前的$i$个人干什么。
对于$sta$需要分类讨论,代码里有注释
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
const int MAXN = 1e5 + , INF = 1e9 + ;
inline int read() {
char c = getchar(); int x = , f = ;
while(c < '' || c > '') {if(c == '-') f = -; c = getchar();}
while(c >= '' && c <= '') x = x * + c - '', c = getchar();
return x * f;
}
int N, x, y, z, A, B;
int f[][][][];
void Min(int &x, int y) {
if(y < x) x = y;
}
main() {
#ifdef WIN32
freopen("a.in", "r", stdin);
#endif
N = read(); x = read(); y = read(); z = read(); A = read(); B = read();
int ans = INF;
memset(f, 0xf, sizeof(f));
f[N][][][] = ;
for(int i = N; i <= ; i++) {
for(int sta = ; sta <= ; sta++) {
for(int a = ; a <= max(A, z); a++) {//已经有了a的金钱
for(int b = ; b <= B; b++) {//b的荣誉
if(f[i][a][b][sta] < ans) {
int cur = f[i][a][b][sta];
if(a >= A && b >= B) {ans = min(ans, cur); continue;}
for(int pep = ; pep <= i; pep++) {//有i个人挣钱
int na = min(a + pep * x, max(A, z)), nb = min(B, b + y * (i - pep));
if(sta == ) {
Min(f[i][na][nb][], cur + );
if(na >= z) Min(f[i][na - z][nb][], cur + );
}
//当前没有发广告,接下来可以不发广告,可以发广告
else if(sta == || sta == ) Min(f[i][na][nb][sta + ], cur + );
//当前已经发了广告,只能等着。。
else {
Min(f[i + ][na][nb][], cur + );
if(na >= z) Min(f[i + ][na - z][nb][], cur + );
}
//当前发完了广告,考虑是否继续发广告
}
}
// if(f[i][a][b][sta] <= 100000)printf("%d %d %d %d %d\n", i, a, b, sta, f[i][a][b][sta]);
}
}
} }
printf("%d", ans);
}
BZOJ1569: [JSOI2008]Blue Mary的职员分配(dp 暴力)的更多相关文章
- bzoj千题计划192:bzoj1569: [JSOI2008]Blue Mary的职员分配
http://www.lydsy.com/JudgeOnline/problem.php?id=1569 dp[i][j][a][b] 表示i个职员,发广告状态为j,已有金钱a,声誉b的最少天数 j= ...
- [bzoj1569][JSOI2008][Blue Mary的职员分配]
Description 由于Blue Mary呕心沥血的管理,Blue Mary的网络公司蒸蒸日上.现在一共拥有了n名职员,可惜没有任何的金钱和声誉.平均每名每天职员都可以给公司带来x单位金钱或者y单 ...
- [JSOI2008]Blue Mary的职员分配
由于Blue Mary呕心沥血的管理,Blue Mary的网络公司蒸蒸日上.现在一共拥有了n名职员,可惜没有任何的金钱和声誉.平均每名每天职员都可以给公司带来x单位金钱或者y单位声誉(名利不能双全). ...
- bzoj1567: [JSOI2008]Blue Mary的战役地图
将矩阵hash.s[0]忘了弄成0,输出中间过程发现了. hash.sort.判重.大概这样子的步骤吧. #include<cstdio> #include<cstring> ...
- 数据结构(线段树):BZOJ 1568 [JSOI2008]Blue Mary开公司
1568: [JSOI2008]Blue Mary开公司 Time Limit: 15 Sec Memory Limit: 162 MBSubmit: 602 Solved: 214[Submit ...
- BZOJ 1567: [JSOI2008]Blue Mary的战役地图( 二分答案 + hash )
二分答案, 然后用哈希去判断... ------------------------------------------------------------------------- #include ...
- bzoj千题计划219:bzoj1568: [JSOI2008]Blue Mary开公司
http://www.lydsy.com/JudgeOnline/problem.php?id=1568 写多了就觉着水了... #include<cstdio> #include< ...
- 【BZOJ1568】[JSOI2008]Blue Mary开公司(李超线段树)
[BZOJ1568][JSOI2008]Blue Mary开公司(李超线段树) 题面 BZOJ 洛谷 题解 是模板题啊. #include<iostream> #include<cs ...
- [BZOJ 1568][JSOI2008]Blue Mary开公司
[BZOJ 1568][JSOI2008]Blue Mary开公司 题意 \(n\) 次操作, 维护一个一次函数集合 \(S\). 有两种操作: 给定 \(b\) 和 \(k\), 向 \(S\) 中 ...
随机推荐
- CSP学习之CryptoAPI初识
Crypto API目的就是提供开发者在windows下使用PKI的编程接口. Crypto 提供了很多的加解密相关函数,如编码.解码.加密解密,哈希,数字证书.证书管理证书存储等. 有关 ...
- Java日志框架解析及实战分析
转载自: https://zhuanlan.zhihu.com/p/24272450 https://zhuanlan.zhihu.com/p/24275518 作为Java程序员,幸运的是,Java ...
- scss-@if指令
@if指令接受表达式和使用嵌套样式,无论表达式的结果只不过是false或null. 语法: @if expression { //CSS codes are written here } scss实例 ...
- CSS深入理解学习笔记之border
1.border-width border-width为何不支持百分比:语义和使用场景决定的,现实中各种边框本身的概念就不存在百分比的使用方法. border-width支持关键字:thin.medi ...
- Linux虚拟系统安装——Ubuntu18.04 & CentOS6.5
Linux虚拟系统安装--Ubuntu18.04 & CentOS6.5 摘要:Linux简介.虚拟系统安装.系统备份与文件介绍 1. Linux简介 (1)1968年,MIT.Bell实验室 ...
- Eclipse SWT
Reference: http://www.eclipse.org/swt/ http://www.functionx.com/win32/Lesson01.htm http://www.win32d ...
- 用ESP8266 WIFI模块连接服务器,并实现与服务器相互通讯
最近在做一个智能锁的项目,该项目要求实现在任何地方(当然是要有网络的)可以在手机上用APP开锁.而我负责的部分主要是实现底层与服务器连接,并且要能相互通讯.考虑了很多问题,最终选择了用ESP8266 ...
- WebLogic配置与部署
一.创建域: 第一步,选择“开始菜单”-> “Oracle WebLogic”-> “WebLogic Server 10gR3” -> “Tools”-> “Configur ...
- VC++动态链接库(DLL)编程
一.概论 1:http://www.pconline.com.cn/pcedu/empolder/gj/vc/0509/698632.html 2:http://pcedu.pconline.com. ...
- 【Spring实战】—— 15 Spring JDBC模板使用
前一篇通过对传统的JDBC的使用操作,可以体会到使用的繁琐与复杂,套句话说,是用了20%作了真正的工作,80%作了重复的工作. 那么通过本篇,可以了解如下的内容: 1 如何配置数据源 2 如何在spr ...