9710134 | CodeChef


#include<bits/stdc++.h>
using namespace std;
int main()
{
int test;
cin>>test;
while(test–)
{

vector<pair<int,int> >vect;
int n,i,t;
cin>>n;
for(i=0;i<n;i++)
{
cin>>t;
vect.push_back(make_pair(0,t));
}
int l=n,j;
while(l!=vect[0].second)
{
for(j=0;j<l;j++)
{

      if(vect[j].first==vect[j].second)
     {
         l=vect[j].second;
         break;
     }
     vect[j].first=vect[j].first+1;

 }

}
int sum=0;
for(i=0;i<n;i++)
{
sum=sum+vect[i].first;
}
cout<<sum<<endl;
}

}
what is the mistake in my code i got WA and TLE as well