QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#34495#4238. Zero SumyzhangWA 136ms4780kbC++171.4kb2022-06-10 09:55:002022-06-10 09:55:03

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-06-10 09:55:03]
  • 评测
  • 测评结果:WA
  • 用时:136ms
  • 内存:4780kb
  • [2022-06-10 09:55:00]
  • 提交

answer

//μ's forever
#include <bits/stdc++.h>
#define N 35005
#define ll long long
//#define getchar nc
using namespace std;
inline char nc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
inline int read()
{
    register int x=0,f=1;register char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9')x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
    return x*f;
}
inline void write(register int x)
{
    if(!x)putchar('0');if(x<0)x=-x,putchar('-');
    static int sta[20];register int tot=0;
    while(x)sta[tot++]=x%10,x/=10;
    while(tot)putchar(sta[--tot]+48);
}
int n,k,a[N][7],p[N];
ll f[405],g[405];
int bas=200;
int main()
{
    n=read(),k=read();
    for(int i=1;i<=n;++i)
        for(int j=-k;j<=k;++j)
            a[i][j+k]=read();
    for(int i=1;i<=n;++i) p[i]=i;
    random_shuffle(p+1,p+1+n);
    memset(f,0x3f,sizeof(f));
    f[bas]=0;
    for(int i=1;i<=n;++i){
        int x=p[i];
        memset(g,0x3f,sizeof(g));
        for(int l=0;l<=400;++l){
            if(f[l]!=0x3f3f3f3f3f3f3f3f){
                for(int j=-k;j<=k;++j)
                    if(l+j>=0&&l+j<=400){
                        g[l+j]=min(g[l+j],f[l]+a[x][j+k]);
                    }
            }
        }
        memcpy(f,g,sizeof(g));
    }
    printf("%lld\n",f[bas]);
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 3704kb

input:

3 1
3 14 15
-3 -5 -35
2 71 82

output:

-19

result:

ok 1 number(s): "-19"

Test #2:

score: 0
Accepted
time: 2ms
memory: 3696kb

input:

5 2
1 2 5 14 42
1 2 3 5 8
1 2 4 8 16
1 2 3 4 5
1 2 6 24 120

output:

16

result:

ok 1 number(s): "16"

Test #3:

score: 0
Accepted
time: 0ms
memory: 3736kb

input:

10 2
-904071845 760493887 -478285804 759035367 -680013382
-587322944 665345507 -20509293 103731947 864888628
738633646 936703855 -370523881 301151360 478433861
703775172 -913389861 691762973 -185132991 543994805
-511007159 118916858 891184 349354959 267412081
-663269925 14450557 369277951 237764429 ...

output:

-6259997315

result:

ok 1 number(s): "-6259997315"

Test #4:

score: 0
Accepted
time: 0ms
memory: 3700kb

input:

10 2
-566639283 -281454349 687175663 817449090 928108928
-819788458 -442586076 -451652406 403601435 -168825683
-649266596 187412594 -856159947 476347172 20574258
-390470703 -791341926 -60895976 842388030 507828204
159048971 -531035734 -110061386 255061473 -622553675
767534638 296274618 318355641 -60...

output:

-5863402983

result:

ok 1 number(s): "-5863402983"

Test #5:

score: -100
Wrong Answer
time: 136ms
memory: 4780kb

input:

35000 2
-323024395 123746159 618869974 -455533063 294962647
9971372 784839881 -906564905 -578266269 944975915
968956358 -576765224 448197684 986539127 -525297570
-745293354 426913995 129954892 255813154 -243728523
-922616050 -983803120 -317189892 362753890 481320837
-626411581 760532893 481031139 14...

output:

-23326090550215

result:

wrong answer 1st numbers differ - expected: '-23326299571078', found: '-23326090550215'