0
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t,n;
    cin>>t;
    for(int i=1;i<=t;i++)
    {
        int c=0;int C[t]={};
        cin>>n;
        int P[n]={};int G[n]={};
        for(int j=0;j<n;j++)
        {
            cin>>P[j];
        }
        for(int k=0;k<n;k++)
        {
            int asn=1;int b=5;
            if(k!=0)
            {
            if(k<5)
            {
                for(int l=0;l<k;l++)
                {
                    if(P[l]<P[k])
                    {
                        asn*=0;
                    }

                }
            }
            else
            {
                while(b>0)
                {
                    if(P[k-b]<P[k])
                    {
                        asn*=0;
                    }

                    b--;
                }
            }
            }
            G[k]=asn;
        }

    for(int f=0;f<n;f++)
    {
        if(G[f]==1)
        {
            c++;
        }
    }
  cout<<c<<"\n";
    }
}

Can anyone please help me in finding the SIGTSTP error in this code.In my PC this program works fine but gives a run-time error while compiling in Codechef's online IDE. The link to the problem is https://www.codechef.com/OCT19B/problems/S10E

RKRK
  • 1,354
  • 5
  • 14
  • 17
Priyam33
  • 1
  • 2
  • Welcome to Stack Overflow! First, you should *never* `#include `. It is not proper C++. It ruins portability and fosters terrible habits. Questions using it will usually be downvoted on Stack Overflow. See [Why should I not `#include `](https://stackoverflow.com/q/31816095). Second, please try to avoid `using namespace std;` because it is considered bad practice. See [Why is “using namespace std;” considered bad practice?](https://stackoverflow.com/q/1452721) ... – L. F. Oct 06 '19 at 13:43
  • ... Third, please use `std::vector` instead of the non-standard variable length arrays. See [Why aren't variable-length arrays part of the C++ standard?](https://stackoverflow.com/q/1887097) Fourth, please fix the indentation to make the code more readable. Now, go through your code in a debugger and isolate the problematic code. You can present the isolated code in the form of a [mre] and ask for help. – L. F. Oct 06 '19 at 13:45
  • I suspect those IDEs interrupt your program when it runs longer than some predefined time. – Igor Tandetnik Oct 06 '19 at 14:51
  • Thank you @Igor Tandetnik – Priyam33 Oct 08 '19 at 08:11

0 Answers0