QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#412001#795. Cloud ComputingsichengzhouCompile Error//C++141.9kb2024-05-15 22:50:122024-05-15 22:50:15

Judging History

This is the latest submission verdict.

  • [2024-05-15 22:50:15]
  • Judged
  • [2024-05-15 22:50:12]
  • Submitted

answer

#include<iostream>
using namespace std;
typedef long long LL;
const int N=2e3+10;
int n,m;
struct Node{
    int c,f,v;
    bool operator <(const Node &t)const
    {
        return f<t.f;
    }
}a[N],b[N];
LL f[N][51],g[N][51];
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d%d%d",&a[i].c,&a[i].f,&a[i].v);
    }
    sort(a+1,a+n+1);
    scanf("%d",&m);
    for(int i=1;i<=m;i++)
    {
        scanf("%d%d%d",&b[i].c,&b[i].f,&b[i].v);
    }
    sort(b+1,b+m+1);
    memset(f,0x3f,sizeof(f));
    f[m+1][0]=0;
    for(int i=n+1;i>=2;i--)
    {
        for(int j=m+1;j>=2;j--)
        {
            for(int k=0;k<=50;k++)
            {
                f[j-1][k]=min(f[j-1][k],f[j][k]);
                if(k>=b[j-1].c&&a[i].f>=b[j-1].f)
                {
                    f[j-1][k-b[j-1].c]=min(f[j-1][k-b[j-1].c],f[j][k]-b[j-1].v);
                }
            }
        }
    //    cout<<i<<endl;
        memset(g,0x3f,sizeof(g));
        for(int j=m+1;j>=1;j--)
        {
            for(int k=0;k<=50;k++)
            {
            //    if(f[j][k]<1e18)cout<<j<<' '<<k<<' '<<f[j][k]<<endl;
                g[j][k]=min(g[j][k],f[j][k]);
                if(k+a[i-1].c<=50)
                {
                    g[j][k+a[i-1].c]=min(g[j][k+a[i-1].c],f[j][k]+a[i-1].v);
                }
                if(k+a[i-1].c-b[j-1].c<=50&&k+a[i-1].c-b[j-1].c>=0&&a[i-1].f>=b[j-1].f)
                {
                    g[j-1][k+a[i-1].c-b[j-1].c]=min(g[j-1][k+a[i-1].c-b[j-1].c],f[j][k]+a[i-1].v-b[j-1].v);
                }
            }
        }
        memcpy(f,g,sizeof(g));
    }
    LL ans=0x3f3f3f3f3f3f3f3f;
    for(int k=0;k<=50;k++)
    {
        ans=min(ans,f[1][k]);
    }
    printf("%lld\n",-ans);
    return 0;
}
/*
4
4 2200 700
2 1800 10
20 2550 9999
4 2000 750
3
1 1500 300
6 1900 1500
3 2400 4550
*/

Details

answer.code: In function ‘int main()’:
answer.code:21:5: error: ‘sort’ was not declared in this scope; did you mean ‘short’?
   21 |     sort(a+1,a+n+1);
      |     ^~~~
      |     short
answer.code:28:5: error: ‘memset’ was not declared in this scope
   28 |     memset(f,0x3f,sizeof(f));
      |     ^~~~~~
answer.code:2:1: note: ‘memset’ is defined in header ‘<cstring>’; did you forget to ‘#include <cstring>’?
    1 | #include<iostream>
  +++ |+#include <cstring>
    2 | using namespace std;
answer.code:61:9: error: ‘memcpy’ was not declared in this scope
   61 |         memcpy(f,g,sizeof(g));
      |         ^~~~~~
answer.code:61:9: note: ‘memcpy’ is defined in header ‘<cstring>’; did you forget to ‘#include <cstring>’?
answer.code:16:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   16 |     scanf("%d",&n);
      |     ~~~~~^~~~~~~~~
answer.code:19:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   19 |         scanf("%d%d%d",&a[i].c,&a[i].f,&a[i].v);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
answer.code:22:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   22 |     scanf("%d",&m);
      |     ~~~~~^~~~~~~~~
answer.code:25:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   25 |         scanf("%d%d%d",&b[i].c,&b[i].f,&b[i].v);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~