#include <stdio.h> #include <climits> #include <algorithm> using namespace std; /* Codeforces */ /*****************************************************************************/ int main(void) { int v, d[10], n, m=INT_MAX; scanf("%d", &v); for (int i=1; i<=9; i++) { scanf("%d", &d[i]); m=min(m, d[i]); } if (m>v) puts("-1"); else { n=v/m; while (n--) for (int i=9; i>0; i--) if (v>=d[i]&&(v-d[i])/m==n) { printf("%d", i); v-=d[i]; break; } puts(""); } return 0; } /*****************************************************************************/
Codeforces 202 DIV2 B
又是简单贪心:..
Subscribe to:
Post Comments
(
Atom
)
No comments :
Post a Comment