showing wrong answer?

#include
using namespace std;

int main() {
int t;
cin>>t;int max,count=1,n,num;
while(t–)
{

cin>>n>>max;
while(--n)
{
    cin>>num;
    if(max>=num){
    max=num;++count;}
}
cout<<count;

}

return 0;

}

Hi @abhishek818

  • The first mistake is that you have initialised the count variable outside the t loop. It needs to be re-initialised for every test case.
  • The next mistake is that you have to print each output in a new line. So add an endl in the cout.

Here is your fixed code -


[1].

Hope this helped :)


  [1]: https://www.codechef.com/viewsolution/23604919
//