• 【codevs1163】访问艺术馆


    problem

    solution

    codes

    //f[i,j]表示用j秒回到i最多拿几幅画
    //链式建树
    #include<iostream>
    #include<algorithm>
    using namespace std;
    const int maxn = 1010;
    int tot, n(1), f[maxn][maxn];//n是节点编号
    void dp(int root){
        int time, pic;
        cin>>time>>pic;
        time *= 2;  //走廊要走两遍
        if(!pic){
            int lch(++n), rch(++n);
            dp(lch);
            dp(rch);
            //?无法确定时间,因为祖先节点时间没有考虑进去,所以当前剩下的时间不知道,所以枚举所有状态
            for(int i = time; i<= tot; i++)
                for(int j = 0; j <= i-time; j++)
                    f[root][i]=max(f[root][i], f[lch][j]+f[rch][i-time-j]);
        }else{
            for(int i = time; i <= tot; i++)
                f[root][i] = min(pic,(i-time)/5);
        }
    }
    int main(){
        cin>>tot;
        dp(1);
        cout<<f[1][tot]<<"
    ";
        return 0;
    }
  • 相关阅读:
    maven常用命令介绍(持续更新)
    JQ笔记
    AspNetPager学习使用2
    AspNetPager学习使用1
    VS2012添加ADO实体数据模型
    手动拍摄0008
    程序自动拍摄0007
    曝光补偿0006
    白平衡0005
    感光度0004
  • 原文地址:https://www.cnblogs.com/gwj1314/p/9444794.html
Copyright © 2020-2023  润新知