@YYR RE最后一个点,求助,,,,

P1417 烹调方案

Sshenyyyu @ 2018-10-31 21:07:12

#include <cstdio>
#include <cmath>
#include <deque>
#include <stack>
#include <queue>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <iostream>
using namespace std;
#define ll long long
#define ull unsigned long long

const int Maxn=100001;
const int inf=2147483647;

ll n,m,T;
ll f[Maxn];
struct node { ll a,b,c; }p[Maxn];
bool cmp(node a,node b) {
    return a.c*b.b<=b.c*a.b;
}   
ll ma(ll a,ll b) { return a>b?a:b; }
int main() {
    scanf("%lld%lld",&T,&n);
    for(ll i=1; i<=n; i++) scanf("%lld",&p[i].a);
    for(ll i=1; i<=n; i++) scanf("%lld",&p[i].b);
    for(ll i=1; i<=n; i++) scanf("%lld",&p[i].c);
    sort(p+1,p+n+1,cmp);
    f[0]=0;
    for(ll i=1; i<=n; i++)
        for(ll j=T; j>=p[i].c; j--) 
            f[j]=max(f[j],f[j-p[i].c]+p[i].a-(j*p[i].b));
    ll ans=0;
    for(ll i=1; i<=T; i++)
        ans=ma(ans,f[i]);
    printf("%lld\n",ans);
    return 0;
}

by Sshenyyyu @ 2018-10-31 22:30:23


by Sshenyyyu @ 2018-10-31 22:30:48

yg很烧饼,我吃东西吃好了,做题了


上一页 |