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

By |2017-08-05T21:39:07+00:00August 5th, 2017|Categories: C/C++, Programming|Tags: , , |

#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); [...]