QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#34496 | #4238. Zero Sum | yzhang | WA | 327ms | 4932kb | C++17 | 1.4kb | 2022-06-10 09:56:03 | 2022-06-10 09:56:06 |
Judging History
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[805],g[805];
int bas=400;
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<=800;++l){
if(f[l]!=0x3f3f3f3f3f3f3f3f){
for(int j=-k;j<=k;++j)
if(l+j>=0&&l+j<=800){
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;
}
詳細信息
Test #1:
score: 100
Accepted
time: 2ms
memory: 3668kb
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: 3612kb
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: 2ms
memory: 3700kb
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: 2ms
memory: 3724kb
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: 0
Accepted
time: 265ms
memory: 4888kb
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:
-23326299571078
result:
ok 1 number(s): "-23326299571078"
Test #6:
score: 0
Accepted
time: 283ms
memory: 4748kb
input:
35000 3 -389986454 -678028773 330282316 582141258 -976039033 415560778 -256794145 891726219 -744524869 671251658 67347457 -91229912 -787543984 364694820 606490044 511500731 766802212 79214055 -745406592 -843185684 -709300461 -806048178 750955329 92731052 -740911920 943335651 -961204999 72788590 5815...
output:
-26267884225753
result:
ok 1 number(s): "-26267884225753"
Test #7:
score: 0
Accepted
time: 275ms
memory: 4860kb
input:
35000 3 -205476456 82285866 -35594070 0 53353652 -49927864 -111238731 113551347 -133551112 19375782 0 -89200221 121851958 207015309 57966468 -78468406 -89972877 0 -14958562 -153791584 207214716 41705397 -138035132 34758504 0 -91078140 3818342 -281759472 199952820 -173442272 -63649020 0 69365700 -761...
output:
-5671382440154
result:
ok 1 number(s): "-5671382440154"
Test #8:
score: 0
Accepted
time: 327ms
memory: 4884kb
input:
35000 3 -104465988 -61243572 -85539391 0 7491458 10264978 124155243 -268558005 -154632718 -21620750 0 27153711 122054610 116554080 -37253310 -179203364 -12517155 0 24722702 80407004 66380241 -37560414 -147869008 -55350255 0 21547694 5632026 174871269 -209389992 -184668276 -34948820 0 9415470 8251568...
output:
-6078227814541
result:
ok 1 number(s): "-6078227814541"
Test #9:
score: 0
Accepted
time: 298ms
memory: 4796kb
input:
35000 3 902444553 382219274 435764110 878892951 655614413 151116197 232298986 213739238 198177043 698942673 772039014 372652389 180586024 6396281 87942969 598386916 -49947342 39272933 968460479 949268130 968282113 738343828 95663007 635955539 -9208067 652112369 431840638 284151628 -58473132 30378755...
output:
-14462236943288
result:
ok 1 number(s): "-14462236943288"
Test #10:
score: 0
Accepted
time: 284ms
memory: 4880kb
input:
35000 3 113961247 593708547 248864537 180118601 925518310 15254920 577036150 279961671 63364217 713049091 937580207 329002834 77859362 357285128 881748603 693652749 303956346 894180781 819899770 372981112 353387093 365389658 535559085 447104136 272739305 115939848 179347884 709464863 -99411860 39686...
output:
-636458673506
result:
ok 1 number(s): "-636458673506"
Test #11:
score: 0
Accepted
time: 280ms
memory: 4812kb
input:
35000 3 671257145 87472903 647195116 960778581 327005775 269169516 123922983 284052436 853466191 395187549 872459399 961583162 671293207 31377460 162077596 758965589 964095767 356305312 941818506 841868937 18061159 929743495 443985166 961520354 537431927 982805255 484995037 848027892 352415069 16624...
output:
2382205891728
result:
ok 1 number(s): "2382205891728"
Test #12:
score: 0
Accepted
time: 283ms
memory: 4932kb
input:
35000 3 286266440 749544229 845081932 986126225 704197478 357932327 320262234 902658169 983782929 248169641 394709844 753187053 797399106 340299748 503097699 845504290 694061174 426893618 549257450 280583394 156194149 639874747 779111479 478326212 760154985 621391283 900712823 131080194 202287918 82...
output:
7437279629050
result:
ok 1 number(s): "7437279629050"
Test #13:
score: 0
Accepted
time: 282ms
memory: 4884kb
input:
35000 3 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -100...
output:
-35000000000000
result:
ok 1 number(s): "-35000000000000"
Test #14:
score: -100
Wrong Answer
time: 280ms
memory: 4856kb
input:
35000 3 -214231740 561828360 76241266 472660258 242381160 463748494 755426285 -338249027 670482502 925122567 34876129 665851249 806877747 763800269 -645259236 835667403 720749523 533537248 -631174 208763832 285452509 -247662789 453838584 609124240 906898701 373237786 808969422 11914645 -432735167 53...
output:
-17514688000528
result:
wrong answer 1st numbers differ - expected: '-17515051871501', found: '-17514688000528'