本地过了,luogu pts15qwq

P1417 烹调方案

NEO_bone @ 2022-08-20 07:44:57


#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#define ll long long
using namespace std;
ll t,n,ans;
struct food{
    ll a,b,c;
}f[55];
ll dp[100005];
int cmd(food a,food b)
{
    a.b*b.c>a.c*b.b;
}
int main()
{
    cin>>t>>n;
    for(ll i=1;i<=n;i++)
    cin>>f[i].a;
    for(ll i=1;i<=n;i++)
    cin>>f[i].b;
    for(ll i=1;i<=n;i++)
    cin>>f[i].c;
    sort(f+1,f+1+n,cmd);
    for(ll i=1;i<=n;i++)
    for(ll l=t;l>=f[i].c;l--)
    dp[l]=max(dp[l],dp[l-f[i].c]+f[i].a-l*f[i].b);
    for(ll i=1;i<=t;i++)
    ans=max(ans,dp[i]);
    cout<<ans<<endl;
    return 0;
}

by NEO_bone @ 2022-08-20 07:52:57

这里指的是数据下载后本地评测能过,但luogu15分

评测记录


by int_R @ 2022-08-20 08:39:09

int cmd?

甚至还没有return;

bool cmd(food a,food b)
{
    return a.b*b.c>a.c*b.b;
}

by int_R @ 2022-08-20 08:39:29

@jcer_lazy_bone


by NEO_bone @ 2022-08-20 08:42:14

ok,thanks


by NEO_bone @ 2022-08-20 08:43:26

还真是这个,此贴完


|