zoukankan      html  css  js  c++  java
  • P1782 旅行商的背包

    #include <cmath>
    #include <queue>
    #include <cstdio>
    #include <vector>
    #include <cstring>
    #include <iostream>
    #include <algorithm>
    #define int long long
    using namespace std;
    
    const int A = 1e7+10;
    const int B = 1e7+10;
    const int mod = 1e9 + 7;
    const int inf = 0x3f3f3f3f;
    
    inline int read() {
      char c = getchar();
      int x = 0, f = 1;
      for ( ; !isdigit(c); c = getchar()) if (c == '-') f = -1;
      for ( ; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48);
      return x * f;
    }
    
    int n,m,C,cnt,w[B],v[B],f[B];
    
    
    
    main()
    {
        int a,b,s;
        n=read();m=read(),C=read();
        for (int i=1;i<=n;i++)
        {
            a=read(),b=read(),s=read(); 
            int r=1;
            while (s)
            {
                w[++cnt]=a*r;v[cnt]=r*b;s-=r;r<<=1;
                if (s<=r) 
                {w[++cnt]=a*s;v[cnt]=s*b;s=0;}
            }
        }
        
        for (int i=1;i<=cnt;i++)
            for (int j=C;j>=w[i];j--)
                f[j]=max(f[j],f[j-w[i]]+v[i]);
        
        for (int i=1;i<=m;i++)
        {
            int a,b,c;
            a=read(),b=read(),c=read();
            for (int j=C;j>=0;j--)
            {
                for(int k = 0; k <= j; k++)
                    f[j]=max(f[j],f[j-k]+a*k*k+b*k+c);
            }
        }
        
        printf("%lld",f[C]);
    }
    
    
  • 相关阅读:
    sprint 1 的总结
    2016-11-23(第十天)
    2016-11-22(第九天)
    2016-11-20(第七天)
    2016-11-19(第六天)
    2016-11-18(第五天)
    sprint1_11.15燃尽图(第二天)
    OrderSys---Spring 计划(第一天)
    团队信息
    Scrum 4.0
  • 原文地址:https://www.cnblogs.com/lToZvTe/p/14534074.html
Copyright © 2011-2022 走看看