UVA 11661 - Burger Time?

Problem PDF

Solution:

#include
#include
char a[2000010];
int main()
{
    int n,i,d,min,f;
    while(scanf("%d",&n)==1)
    {
        if(n==0)
        break;
        scanf("%s",a);
        f=0;
        d=1;
        min=2000010;
        for(i=0;id)
                min=d;
                i--;
                d=1;
                break;

            }
            else if(a[i]=='Z')
            {
              min=0;
              f=1;
              break;
            }

            }
        }
        else if(a[i]=='D')
        {
            i++;
            for(i=i;id)
                min=d;
                i--;
                d=1;
                break;
            }
            else if(a[i]=='Z')
            {
              min=0;
              f=1;
              break;
            }

            }

        }
        else
        continue;
    }
    printf("%d\n",min);
    }
    return 0;
}
https://github.com/Shipu/OnlineJudgeProblemSolutionWithCPlusPlus/tree/master/uva/11661/11661.cpp