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\) 中 ...
随机推荐
- mysql七:索引原理与慢查询优化(待完整)
一.介绍 索引在MySQL中也叫做“键”,是存储引擎用于快速找到记录的一种数据结构.索引对于良好的性能非常关键,尤其是当表中的数据量越来越大时,索引对于性能的影响愈发重要. 索引优化应该是对查询性能优 ...
- 单链表的插入伪算法和用C语言创建单链表,并遍历
非循环单链表插入结点伪算法讲解 q插入p之后的伪算法:第一种表示方法:r = p->pNext; // p->pNext表示的是所指向结点的指针域,指针域又是指向下一个结点的地址p-> ...
- Daemon 自更新
NSTask *task = [[NSTask alloc] init]; [task setLaunchPath:@"usr/bin/dpkg"]; [task setArgum ...
- Fiddler-修改HTTP请求参数
在进行 App 测试时,经常需要修改请求参数,以获得不同的显示效果,以查看相应的页面显示处理.例如:可以通过修改 HTTP请求 的参数,来获取不同的响应结果. 下面以修改 HTTP请求的商品系统编号为 ...
- @Component 注解
@Component a) 初始化的名字默认为类名首字母小写:UserService 在容器中默认为 userService b) 可以指定初始化 bean 的名字: @Component(valu ...
- Java—集合框架 Collections.sort()、Comparable接口和Comparator接口
Collentions工具类--java.util.Collections Collentions是Java集合框架中,用来操作集合对象的工具类,也是Java集合框架的成员,与List.Map和Set ...
- 2.安装 Android SDK
安装Android SDK Android SDK(Software Development Kit,软件开发工具包)提供了 Android API 库和开发工具构建,测试和调试应用程序.简单来讲,A ...
- 如何使用Putty登录安装在VirtualBox里的ubuntu
我是在Windows操作系统里用VirtualBox安装了ubuntu操作系统. 在VirtualBox里操作ubuntu的终端不是很方便,比如我想在Windows里复制一些命令到ubuntu的终端执 ...
- expected expression __bridge
版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/u013020103/article/details/30491117 expected expres ...
- Photoshop 画布的渐变填充
之前丢掉的要开始慢慢的捡起来,因为学如逆水行舟,不进则退.古人诚不欺我等. 1.新建图层,或者就在当前图层进行操作,选择图层 2.工具箱---1渐变工具---2径向渐变---模式--正常.不透明100 ...