ANUWTA - Editorial

Why is Dynamic Programming solution giving TLE?

#include<bits/stdc++.h>
using namespace std;
long long int arr[100001];

inline void scani(int *a){
register char c=0;
while (c<33) c=getchar();
*a=0;
while (c>33)
{
*a=a10+c-‘0’;
c=getchar();
}
}

int main(void)
{
int t,i,n;
scani(&t);
arr[0]=0;
arr[1]=2;
arr[2]=5;
while(t–)
{
scani(&n);
for(i=3;i<=n;++i)
{
arr[i]=i+i+1+arr[i-2];
}
printf("%lld\n",arr[n]);
}
}

@aijajkhan see this solution -> https://www.codechef.com/viewsolution/10045155
Here i precomputed the cost of all the lights from 0 to 10^5. Then displayed them as the value is entered.

I’m getting TLE inspite of using DP.Please help.
here’s the link to my solution:
https://www.codechef.com/viewsolution/10871878