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\) 中 ...
随机推荐
- Redis过期设置
Redis支持按key设置过期时间,过期后值将被删除(在客户端看来是补删除了的) 用TTL命令可以获取某个key值的过期时间(-1表示永不过期) 127.0.0.1:6379> set name ...
- 慧都启动“正版IDE联合超值推广计划
越来越多的中国软件企业为盗版所害而蒙受巨大损失,正版化意识逐渐兴起.IDE(集成开发环境)是软件开发.编写代码必备工具,而正版IDE更具有运行更稳定.编码更安全.保障更加完善等特点,逾为中国软件行业企 ...
- 转:什么是4D(DRG、DLG、DOM、DEM)数据?
ps:摘抄地址http://blog.163.com/wangqing_rs/blog/static/16451519120111026102916472/ 什么是4D(DRG.DLG.DOM.DE ...
- 跨平台移动开发_PhoneGap 再次点击返回键切换到桌面效果
PhoneGap 再次点击返回键切换到桌面效果 相关代码 <!DOCTYPE html> <html> <head> <title> PhoneGap ...
- AWS的登录认证。。。
Hello, I’m sorry for any concern regarding the $1.00 Authorization that you see associated with your ...
- 百度地图JavaScript开发入门先知
最近项目紧急开发了一些百度地图的功能,觉得百度地图实数强大!于是今天不忙总结一下,看到不错的文章先转载. 文章出处:https://www.opengps.cn/Blog/View.aspx?id=1 ...
- bootstrap table通过ajax获取后台数据展示在table
1. 背景 bootstrap table 默认向后台发送语法的dataType为 json,但是为了解决跨域问题我们需要将dataType改为jsonp,这时就需要修改bootstrap table ...
- Python 用多线程上传和下载文件
# -*- coding: utf-8 -*- __author__ = 'louis' from ftplib import FTP import multiprocessing import ti ...
- 【LOJ6052】「雅礼集训 2017 Day11」DIV(杜教筛)
点此看题面 大致题意: 求\(1\sim n\)内所有满足\(a>0\)的约数\(a+bi\)的\(a\)之和. 解题思路 首先,我们设\(x=(a+bi)(c+di)(1\le x\le n) ...
- java 线程状态图