zoukankan      html  css  js  c++  java
  • P1417-烹调方案

     1 #include <bits/stdc++.h>
     2 #define maxn 13003
     3 #define _for(i,a,b) for(int i = (a);i < b;i ++)
     4 typedef long long ll;
     5 using namespace std;
     6 inline ll read()
     7 {
     8     ll ans = 0;
     9     char ch = getchar(), last = ' ';
    10     while(!isdigit(ch)) last = ch, ch = getchar();
    11     while(isdigit(ch)) ans = (ans << 1) + (ans << 3) + ch - '0', ch = getchar();
    12     if(last == '-') ans = -ans;
    13     return ans;
    14 }
    15 inline void write(ll x)
    16 {
    17     if(x < 0) x = -x, putchar('-');
    18     if(x >= 10) write(x / 10);
    19     putchar(x % 10 + '0');
    20 }
    21 
    22 ll T,n;
    23 struct P
    24 {
    25     ll a;
    26     ll b;
    27     ll c;
    28 };
    29 P p[52];
    30 
    31 bool cmp(P t1,P t2)
    32 {
    33     return t1.c*t2.b < t2.c*t1.b;
    34 }
    35 ll dp[500003];
    36 int main()
    37 {
    38     T = read(),n = read();
    39     _for(i,1,n+1)
    40         p[i].a = read();
    41     _for(i,1,n+1)
    42         p[i].b = read();
    43     _for(i,1,n+1)
    44          p[i].c = read();
    45     
    46     sort(p+1,p+n+1,cmp);
    47     memset(dp,0,sizeof(dp));
    48     _for(i,1,n+1)
    49         for(int t = T;t >= 0;t --)
    50             if(t>=p[i].c)
    51                 dp[t] = max(dp[t],dp[t-p[i].c] + p[i].a - t * p[i].b);
    52     
    53     ll maxx = 0;
    54     _for(i,0,T+1)
    55         maxx = max(maxx,dp[i]);
    56     write(maxx);
    57     return 0;
    58 }
  • 相关阅读:
    Sublime Text 2.0.2 注册码激活
    常用的接口查询,会持续更新中……
    JavaScript获取访问设备信息
    Param指南
    HTML5调用手机摄像头,仅仅支持OPPOHD浏览器
    GET传值
    关于IE缓存
    浏览器的类别及介绍
    JS调用C#中的变量
    在VS2012中设置默认启动
  • 原文地址:https://www.cnblogs.com/Asurudo/p/11341675.html
Copyright © 2011-2022 走看看