Sunday, February 27, 2011

414 - Machined Surfaces


#include<iostream>
#include<stdio.h>
#include<cstdlib>
using namespace std;
int main()
{
    long int i,k,n,sp=0,min=25,space[12],r;
    //freopen("in.txt","r",stdin);
    char ch,c;
    while(cin>>n&&n)
    {
        r=0;
        scanf("%c",&c);//skipping new line after getting n;
        for(i=0;i<n;)
        {
            scanf("%c",&ch);
            if(ch=='X')continue;
            if(ch==' ')
                sp++;
            else
            {
                if(sp<min)min=sp;
                space[i++]=sp;
                sp=0;
            }
        }
        for(k=0;k<i;k++)
            r+=space[k]-min;
        cout<<r<<endl;
        min=25;
    }
    exit(0);
}

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.