Codeforces Round #427 (Div. 2), problem: (B) The number on the board Solution In C/C++

#include <stdio.h>

int k, c, d[10], ans;
main()
{
scanf(“%d”, &k);
getchar();
while ((c = getchar() – ‘0’) >= 0)
d[c]++, k -= c;
for(c = 0; k > 0; d[c] ? d[c]– : c++)
if(d[c])
ans++, k -= 9 – c;
printf(“%d\n”, ans);
return 0;
}

(Visited 79 times, 1 visits today)

About the Author:

Leave A Comment