Facing unknown SIGEMT error

So, I am facing a SIGEMT error while doing a ZCOPRAC problem [ZCO14003, Smart Phone], the code works as intended when I use it on geeksforgeeks ide but gives me the error when I use it on codechef ide.

#include<bits/stdc++.h>
using namespace std;
int main()
{
long long int T;
long long int N;
long long int Budget[N];
long long int price;
long long int point = floor(N/2);
long long int i = 0;
cin >> N;
for(i; i < N; i++)
    cin >> Budget[i];
sort(Budget, Budget + N);
price = Budget[point + 1];
cout << price*(N - point - 1);
return 0;
}

Link to GFG code: Online Compiler and IDE - GeeksforGeeks

Please, can anyone help this poor novice?

EDIT: SOLVED!

2 Likes

Sorry, I just got my error!
Took me 1.5 hours to realize it.
I defined N, then took its array and then assigned N’s value.
I instead should have assigned N’s value before making the array!

Thank you!

8 Likes

Buddy tell me that , how can ur code run on geeks for geeks ide then…:roll_eyes::roll_eyes::roll_eyes::roll_eyes:

Is there is really need to reply this comment after a year?

3 Likes

U are not even forced to, If u don’t want to reply then just don’t do it na…
However my question was not for u…:expressionless:

I didn’t understood what he had done? Kindly explain.

U just saved my 1.5 hrs…I did something similar (but it still worked on devc++) Thx for telling how u solved it. Btw this mistake was kinda stupidity…