Day 7: Faster crab
This commit is contained in:
parent
e2d56edbaf
commit
95b816e293
1 changed files with 5 additions and 6 deletions
|
@ -7,11 +7,10 @@
|
|||
0,t= 0; c\
|
||||
< n ; c ++ )
|
||||
*p=C,G =0 ,P =0,S=0
|
||||
,c,m=0,n=0,r ,t;for(;fscanf
|
||||
,c,m=0,n=0,t ;for(;fscanf
|
||||
#define A abs(C[c]-P)
|
||||
(stdin,"%i%*c",p)==1;p++,n++)if(*p>m
|
||||
#define R(z) if(P==0||t<z)z =t;
|
||||
)m =*p;for(;P<m;P++){l t+=A;R(S)l for(r =1
|
||||
;r<=A;r++)t+=r;if(!P||t<G)G=t;}printf("Silver:"
|
||||
" %u\n" "Gold: %u"
|
||||
"\n",S ,G);}
|
||||
#define R( z) if (! P|| t< z)z=t;
|
||||
)m=*p;for(;P<m;P++){l t+=A;R(S)l t+=A*(A+1)/
|
||||
2;R(G)}printf ("Silver: %"
|
||||
"u\nGold: " "%u\n",S,G);}
|
||||
|
|
Loading…
Reference in a new issue