思路:

状压DP  枚举子集

//By SiriusRen
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int N=<<;
int w,n,t[N];
struct Node{int w,t;}node[N];
int main(){
scanf("%d%d",&w,&n);
memset(t,0x3f,sizeof(t));
for(int i=;i<n;i++)scanf("%d%d",&node[i].t,&node[i].w);
for(int i=;i<(<<n);i++){
int temp=,tempw=;
for(int j=;j<n;j++)if(i&(<<j))temp=max(temp,node[j].t),tempw+=node[j].w;
if(tempw<=w)t[i]=temp;
}
for(int i=;i<(<<n);i++){
for(int j=i;j;j=(j-)&i)
t[i]=min(t[i],t[j]+t[i^j]);
}printf("%d\n",t[(<<n)-]);
}

BZOJ 2073的更多相关文章

  1. BZOJ 2073: [POI2004]PRZ( 状压dp )

    早上这道题没调完就去玩NOI网络同步赛了.... 状压dp , dp( s ) 表示 s 状态下所用的最短时间 , 转移就直接暴力枚举子集 . 可以先预处理出每个状态下的重量和时间的信息 . 复杂度是 ...

  2. bzoj 2073 暴力

    2073: [POI2004]PRZ Time Limit: 10 Sec  Memory Limit: 64 MBSubmit: 442  Solved: 327[Submit][Status][D ...

  3. BZOJ 2073 [POI2004]PRZ(状压DP)

    [题目链接] http://www.lydsy.com/JudgeOnline/problem.php?id=2073 [题目大意] 任何时候队伍在桥上的人都不能超过一定的限制. 所以这只队伍过桥时只 ...

  4. bzoj 2073: [POI2004]PRZ

    2073: [POI2004]PRZ Description 一只队伍在爬山时碰到了雪崩,他们在逃跑时遇到了一座桥,他们要尽快的过桥. 桥已经很旧了, 所以它不能承受太重的东西. 任何时候队伍在桥上的 ...

  5. Bzoj: 2073 [POI2004]PRZ 题解

    2073: [POI2004]PRZ Time Limit: 10 Sec  Memory Limit: 64 MBSubmit: 401  Solved: 296[Submit][Status][D ...

  6. BZOJ 2073: [POI2004]PRZ [DP 状压]

    传送门 水题不解释 这道题的主要目的在于记录一个枚举子集的技巧 #include <iostream> #include <cstdio> #include <cstri ...

  7. BZOJ 2127: happiness [最小割]

    2127: happiness Time Limit: 51 Sec  Memory Limit: 259 MBSubmit: 1815  Solved: 878[Submit][Status][Di ...

  8. BZOJ 3275: Number

    3275: Number Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 874  Solved: 371[Submit][Status][Discus ...

  9. BZOJ 2879: [Noi2012]美食节

    2879: [Noi2012]美食节 Time Limit: 10 Sec  Memory Limit: 512 MBSubmit: 1834  Solved: 969[Submit][Status] ...

随机推荐

  1. SLAM: 图像角点检测的Fast算法(时间阈值实验)

    作为角点检测的一种快速方法,FastCornerDetect算法比Harris方法.SIft方法都要快一些,应用于实时性要求较高的场合,可以直接应用于SLAM的随机匹配过程.算法来源于2006年的Ed ...

  2. ABP(http://www.aspnetboilerplate.com/)下载初始化

    官网:http://www.aspnetboilerplate.com/ 下载 下载完成后用vs2015打开,是2015,低版本打开可能会出现一些问题 生成项目,Nuget会自动下载需要的类库 ABP ...

  3. Java_Reflect反射

    类是对象,类是java.lang.Class类的实例对象.There is a class named Class class Foo{} public class ClassDemo{ public ...

  4. 初识cocos creator的一些问题

    本文的cocos creator版本为v1.9.01.color赋值cc.Label组件并没有颜色相关的属性,但是Node有color的属性. //如果4个参数,在ios下有问题let rgb = [ ...

  5. 深入了解Spring Boot 核心注解原理

    SpringBoot目前是如火如荼,所以今天就跟大家来探讨下SpringBoot的核心注解@SpringBootApplication以及run方法,理解下springBoot为什么不需要XML,达到 ...

  6. LA 4327

    Panagola, The Lord of city F likes to parade very much. He always inspects his city in his car and e ...

  7. sqlalchemy带条件查询相关应用

    sqlalchemy带条件查询 filter_by与filter filter_by 与filter的区别: 1. filter_by只能取值= filter可以==,!=,>=,<=等多 ...

  8. Basic Memory Structures

    Basic Memory Structures The basic memory structures associated with Oracle Database include: System ...

  9. Python之Mysql及SQLAlchemy操作总结

    一.Mysql命令总结 1.创建库 create database test1; 2.授权一个用户 grant all privileges on *.* to 'feng'@'%' identifi ...

  10. HDU2191_悼念512汶川大地震遇难同胞——珍惜如今,感恩生活(背包/多重背包)

    解题报告 题目传送门 题意: 中文不多说; 思路: 基础多重背包,每一个物品有多个能够选.转换成01背包解. #include <iostream> #include <cstrin ...