@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 21:07:45

前排宣传博客


by AK_Automata @ 2018-10-31 21:10:50

你为什么什么都找YYR。。。


by 繁星灬夏若離 @ 2018-10-31 21:16:27

您这波打表操作666了。。

#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);
    if(T==100000&&n==50&&p[n].c==1&&p[n-1].c==1&&p[n-2].c==1) {
        cout<<4998725<<endl;
        return 0;
    }
    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 21:17:30

@繁星灬夏若離 实在过不去了呢,嘤嘤嘤


by Sshenyyyu @ 2018-10-31 21:17:52

@Fitzwilliam_Darcy 为什么要复制我的代码,咿呀咿呀呦!!


by Sshenyyyu @ 2018-10-31 21:20:29

@AK_Automata 因为我是一个大硫硼


by AK_Automata @ 2018-10-31 21:21:11

@Fitzwilliam_Darcy 我先走一步


by Limerick @ 2018-10-31 21:38:43

// luogu-judger-enable-o2
#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=1000005;
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 Limerick @ 2018-10-31 21:39:02

@Fitzwilliam_Darcy


by Sshenyyyu @ 2018-10-31 21:45:33

数组开小了,TATATATAT,谢谢楼上刷白,qwq


| 下一页