1, Codeforces 349B Color the Fence
2, Link: Http://codeforces.com/problemset/problem/349/B
3. Summary:
Brush the fence. 1-9 each letter to the AI to paint, ask the maximum number of figures can be drawn.
Greed, but also a little test thinking.
#include <bits/stdc++.h>using namespacestd;#defineLL Long Long#defineINF 0x3f3f3f3fintMain () {intv,a[ the]; while(~SCANF ("%d",&v)) {intm=1; for(intI=1; i<=9; i++) {scanf ("%d",&A[i]); if(A[m]>a[i]) m=i; } intNUM=V/A[M];//Find out the maximum number of numbers if(num==0) puts ("-1"); Else { for(intI=0; i<num;i++)//cycle num times, each output can get the largest one{v%=A[m]; for(intj=9; j>=m;j--) { if((A[j]-a[m]) <=v) {//If the number is less than the remaining, the outputv-= (a[j]-a[m]); printf ("%d", J); Break; }}} printf ("\ n"); } } return 0;}
View Code
Codeforces 349B Color The Fence greedy, thinking