WA in Codeforces Round 322 Problem -C

My code for http://codeforces.com/contest/581/problem/C is giving wrong output and I am unable to find where my logic is incorrect

  #include<iostream>
  #include<cmath>
  using namespace std;
   int main()
      {
      long long int n,k,i;
      float a[100];
      long int sum;
      float total=0.0;
      cin>>n>>k;
      for(i=0;i<n;i++)
      cin>>a[i];
      for(i=0;i<n;i++)//I am just skipping that values whose values are 100 while I am adding 1 to every array value untill it reaches 100 or K reduces to 0
         {
         if(a[i]==100)
         continue;

         else
           {
           while(k>=0)
              {
              if(a[i]!=100)
                {
                k--;
                a[i]=a[i]+1.00;
                }

             }

        }

     }

     for(i=0;i<n;i++)
       {
       total=total+(a[i]/10);  //Calculating total
       }
       total=floor((double)(total));
       sum=total;
       cout<<sum;
       return 0;
     }

Hint : What will your output be for input :

3 3

1 8 9

The answer must be 2. Your’s will print 0.

Please remove float a[100].
If N is greater than 100 (eg: 10000), it will give segmentation fault. Declare an array of size 100000.

actually It is giving answer 2 not 0

In Codeforces, you can know where your submission is giving wrong answer by clicking at your submission link. They will provide you the test case for which your program gave wrong answer, your output and expected output according to the problem setter.

//