Solution of problem

#include
using namespace std;
#define MAX_SIZE 100
int main()
{
int arr[MAX_SIZE];
int found = 0;

 int N,i;
cin >> N;
int K;
cin >> K;



for(i=0; i<N; i++)
{
    cin >> arr[i];
}


for(i=0; i<N; i++)
{
  
    if(arr[i] == K)
    {
        found = 1;
        break;
    }
}


if(found == 1)
{
   cout << "1";  
}
else
{
    cout << "-1";
}

return 0;

}

Here, my code description photo and my code when I am run this code then give me runtime error give me any suggestion in my code.

value of N can be greater than MAX_SIZE(100).
upper limit of N is 10^5

1 Like

try long long int

Yes bro that problem also with me , but you can see that in constrain, Ai is <= 10^5 so that you have fixed your array size is 100 and when this codechef compiler run it’s test cases out 100 the size of array your code is give the run time error so that you can defined array of n size array[n].