what is wrong with this approach?.i am getting runtime error but my sample test case is passing.

#include

using namespace std;

int main() {

int t;

cin>>t;

while(t–)

{

long long int k;

int d0,d1;

cin>>k>>d0>>d1;

long long int a[k];

a[0]=d0;

a[1]=d1;

long long int sum=d0+d1;

for(int i=2;i<k;i++)

{

a[i]=sum%10;

sum=sum+a[i];

}

long long int div_by_3=0;

for(int i=0;i<k;i++)

{

div_by_3=div_by_3+a[i];

}

if(div_by_3%3==0)

cout<<“YES”<<endl;

else

cout<<“NO”<<endl;

}

return 0;

}