Code chef compiler is not responding properly

I am solving a question from practice problems. But whenever I am compiling it, is yielding incorrect answer.
I wrote in code: -
if(arr[0] !=5)
{ cout<<“NO” }
and the input I gave:
5 10 5 15
and it’s yielding output as NO.
Now I don’t understand, why is it so.
It should not execute this if statement, but it is executing it…
What shall I do now?

Dont use CC compiler :stuck_out_tongue:
Although I dont think its cc compilers fault.

Then what should I use :sweat_smile: :sweat_smile:

Download an IDE… Codeblocks is good.
Dont use online compilers, they suck.

please put your full code so that it can be checked

1 Like
#include <iostream>
using namespace std;

int main() {
int t;
cin>>t;
while(t>0)
{   int f = 0;
    int n;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    if(arr[0]!=5)
    {   
        cout<<"YES";
        break;
    }
    else
    {  int c=arr[0];
       for(int i=1;i<n;i++)
    {
        if(arr[i]==5)
           { c = c + arr[i];
             f = 1;

           }
        else if((arr[i] - c) == 5)
           {
             c = arr[i] - c;
             f = 1;
             
            }
        else
           {   
               f = 0;   
           }
    }
    }
    if(f==1)
       cout<<"YES";
    else
      cout<<"NO";
    t--;
}
return 0;
}

Ok I’ll try…

i have checked your code for the input
1
5
4 10 5 12 20
and its working fine.

On code chef compiler?

yes bro

what input you were giving?

It might be printing Yes??

ya

Inside If statement, I wrote YES, in order to check what’s the mistake??

But I wrote that if(arr[0] != 5) {cout<<“Yes”;}
So with input as 5 it is executing that statement…

i think you did not give the value of t and n as input.
you just input 5 10 5 15 ??

NO NO… I first gave value of t then n and then the array…

It’s working perfectly in Dev CPP…

so it must be error with compiler sometime it happens

all right