2
1
Fork 0
aoc2021/07/solution.c

18 lines
613 B
C

#include <stdio.h>
#include <stdlib.h>
int main () {int
C [1000 ]={0 },
*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);}