Please it shows me runtime error, how can i fix it?

using namespace std;

bool findMe(int n, int k, int v[]) {

for (int i = 0; i < n; i++) {
    if (v[i] == k)
    return true;
return false;


int main() {
int n, k, v[1000];
cin >> n >> k;

for (int i = 0; i < n; i++)
    cin >> v[i];
if (findMe(n, k, v))
    cout << 1;
    cout << -1;


if n is greater than 1000 initialize your array after taking input of n

Try initializing the array after taking the input n and declare it as “int v[n];”