• 【bzoj1649】Cow Roller Coaster


    傻逼dp题。

    dp[i][j]表示用了i长度已花费成本j所能得到的价值。

    然后枚举一下铁轨随便做了。

    不行就sort一下。

    #include<bits/stdc++.h>
    #define inf 1000000007
    typedef long long ll;
    using namespace std;
    struct Node{int s,c,w,f;}a[100010];
    ll f[1005][1005];
    bool cmp(Node a,Node b){
        if(a.s==b.s)return a.w<b.w;
        return a.s<b.s;
    }
    inline int read(){
        int f=1,x=0;char ch;
        do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');
        do{x=x*10+ch-'0';ch=getchar();}while(ch>='0'&&ch<='9');
        return f*x;
    }
    int l,n,maxv;
    int main(){
        l=read();n=read();maxv=read();
        for(int i=1;i<=n;i++){
            a[i].s=read();a[i].w=read();a[i].f=read();a[i].c=read();
        }
        sort(a+1,a+n+1,cmp);memset(f,-1,sizeof(f));f[0][0]=0;
        for(int i=1;i<=n;i++){
            int len=a[i].s+a[i].w;
            for(int j=maxv;j>=a[i].c;j--)if(f[a[i].s][j-a[i].c]>=0)
            f[len][j]=max(f[len][j],f[a[i].s][j-a[i].c]+a[i].f);
        }
        ll ans=-inf;
        for(int i=0;i<=maxv;i++)ans=max(ans,f[l][i]);
        cout<<ans;
    }
  • 相关阅读:
    delphi实现FTP下载
    delphi中ClientDataSet的隐含功能
    删除注册的ODBC
    ZOJ 1041 Transmitters
    POJ 3232 Accelerator
    POJ 3460 Booksort
    UVa 11552 Fewest Flops
    SOJ 8064 Whack the Groundhog
    BNU OJ 29355 手速为王
    POJ 3322 Bloxorz I
  • 原文地址:https://www.cnblogs.com/zcysky/p/7019836.html
Copyright © 2020-2023  润新知