|
|
вернуться в форумI need help HI! I tried solve this problem, but I always got WA1. I can't find my mistake # include <iostream> using namespace std; main () { char a; int min,hamar; int n,k; int i; int w[500]={0}; int b[500]={0}; cin>>n>>k; for(i=0;i<n;i++) { cin>>a; if(a=='1') b[i]=1; else w[i]=1; } int ans=0; while(n!=k) { min=62500; for(i=0;i<n-1;i++) if(min>w[i]*b[i+1]+w[i+1]*b[i]) { min=w[i]*b[i+1]+w[i+1]*b[i]; hamar=i; } w[hamar]+=w[hamar+1]; b[hamar]+=b[hamar+1]; for(i=hamar+1;i<n;i++) { w[i]=w[i+1]; b[i]=b[i+1]; } n--; ans+=min; } cout<<ans; return 0; } Edited by author 15.12.2008 00:35 Re: To Administrators. Послано Nick J 13 окт 2008 20:01 I could help you but I'm not Administrator. Re: To Administrators. If you can help me to find my mistake, then mail me to mihran91@mail.ru Edited by author 22.10.2008 22:11 |
|
|