关于这一题开long long 比int多拿70pts

P1064 [NOIP2006 提高组] 金明的预算方案

灰的积雨云 @ 2022-10-26 08:50:58

如果我不开longlong 只可以拿30分

但是数据显然不会超longlong 这是为什么呢

#include <cstdio>
#include <iostream>
#define lfor(i, x, y) for (int i = (x); i <= (y); ++ i)
#define llfor(i, x, y) for (int i = (x); i < (y); ++ i)
#define rfor(i, x, y) for (int i = (x); i >= (y); -- i)
#define rlfor(i, x, y) for (int i = (x); i > (y); -- i)
#define For(p) for (int i = head[p]; i; i = nxt[i])
#define vi ver[i]
using namespace std;

typedef long long ll;
const int N = 2e5 + 10;
const int EX = 3;
ll f[N], v[N], p[N], cv[N][EX], cp[N][EX];

int main()
{
    int n, m; scanf("%d %d", &n, &m);
    lfor (i, 1, m)
    {
        ll vi, pi, qi; scanf("%lld %lld %lld", &vi, &pi, &qi);
        if (!qi) {v[i] = vi; p[i] = pi * vi;}
        else {cv[qi][++ cv[qi][0]] = vi; cp[qi][cv[qi][0]] = pi * vi;}
    }
    lfor (i, 1, m)
    {
        if (!v[i]) continue;
        rfor (j, n, v[i])
        {
            f[j] = max(f[j], f[j - v[i]] + p[i]);
            if (j >= v[i] + cv[i][1]) f[j] = max(f[j], f[j - v[i] - cv[i][1]] + p[i] + cp[i][1]);
            if (j >= v[i] + cv[i][2]) f[j] = max(f[j], f[j - v[i] - cv[i][2]] + p[i] + cp[i][2]);
            if (j >= v[i] + cv[i][1] + cv[i][2]) f[j] = max(f[j], f[j - v[i] - cv[i][1] - cv[i][2]] + p[i] + cp[i][1] + cp[i][2]);
        }
    }
    printf("%lld\n", f[n]);
    return 0;
}

by karanoli @ 2022-10-26 09:26:00

#define vi ver[i]

by 灰的积雨云 @ 2022-10-26 09:27:22

我已经找到问题了

就像上一位所说的一样

karanoli你在说什么呢 asdasdasdasdasdas asasdasdasdasdasd


by Amy_Xu @ 2023-07-28 08:13:40

@灰的积雨云 您到底找到什么问题了?


|