2
1
Fork 0

Day 7: Better crab

This commit is contained in:
Mia Herkt 2021-12-07 16:33:24 +01:00
parent 95b816e293
commit 370c901936
Signed by: mia
GPG key ID: 72E154B8622EC191

View file

@ -3,14 +3,15 @@
int main () {int
C [1000 ]={0 },
#define l for(c =\
0,t= 0; c\
< n ; c ++ )
*p=C,G =0 ,P =0,S=0
,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|| 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);}
*p=C,G=0 ,P=0,S=0
#define R(\
x) x=! P|| t<x ?t:x;
,c,m=0 ,n =0 ,t;for
(;scanf("%i%*c" ,p)==1;p++,n
#define A abs(C[c]-P)
#define l( v, x) for(c =0 ,\
t=0; c< n; c++ )t += v ;R(x)
++)m=*p>m?*p:m;for(;P<m;P++){l(A,S)l((A*(A+1
))/2,G)} printf("Silv"
"er: %u\n" "Gold: %u\n"
,S ,G);}