"Spread the Word" CodeChef challenge
Do not do using namespace std; This is a bad habbit that pollutes your namespace needlessly. You are only using std in exaclty 4 places. Its really easy to be better here.
Please use sensible names. Your t is the number of test runs, so name it numTests or something similar. In a month you will never know the meaning of a given variable.
Stay consistent in your code style. You have different styles of for loop. This is really confusing and quite frankly annoying to read.
The question is marked as c++ but you use plain old C here. Rather than a C-style array you should use a std::vector&lt;int&gt;
You are getting timeouts because you use a brute force approach. You should realize, that you can directly calulate the number of infomred people directly. At the first day it is a[0]. At the second day it is a[0] + a[0] + ... a[a[0]]. Consequently you can determine the number of newly informed people for every day just once and reuse that value.