RE on running it but submitting successfully

someone please help me in figuring out why such thing is happening?

#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin>>t;
while(t --)
{
int flag=0;
int n;
cin>>n;
int a[n];
int maxx=0;
map<int,int>m;

   for(int i=0;i<n;i++)
    {
        cin>>a[i];
        m[a[i]]++;
        if(m[a[i]]>=3)
        {
            
            flag=1;
        }
        if (a[i]>maxx)
        {
            maxx=a[i];
        }
        
    }
      if (flag==1)
      {
          cout<<"NO"<<endl;
          continue;
      }
      if (m[maxx]>1)
      {
          cout<<"NO"<<endl;
          continue;
      }
      
          cout<<"YES"<<endl;
          
          for (auto i=m.begin();i!=m.end();i++)
          {
              cout<<i->first<<" ";
              i->second-=1;
          }
          
          for (auto i=m.rbegin();i!=m.rend();i++)
          {
              if(i->second!=0)
                  cout<<i->first<<" ";
              
          }
          cout<<endl;
}

}

you just give input before clicking run .

1 Like

can you please explian…i am not able to get it

You have to give custom input to run your code

1 Like

do not run directly first provide custom input then run the code.

1 Like

okk thanks @hackraj …that means we are always supposed to provide custom input before running a code on codechef ide?? As earlier i have practised on hackerrank ,where it runs sample cases automatically on running the code,where i need not to provide any custom input as such.

On codechef, you need to provide it.

1 Like

you got the point
yes we are always supposed to provide custom input before running a code on codechef ide .

1 Like

An alternative to providing custom input via that box is to compile your testcases into the code. However, you’d then likely have untested code paths for how your program gets its input when you submit the final version…

1 Like