This was my 1st submission to the problem however it failed in test case 2 . Can someone plz help in finding the bug ?
Question link - Problem - A - Codeforces
Solution link - Submission #93673043 - Codeforces
This was my 1st submission to the problem however it failed in test case 2 . Can someone plz help in finding the bug ?
Question link - Problem - A - Codeforces
Solution link - Submission #93673043 - Codeforces
You can see the editorial… & as per your code…you should cut off the reverse and sorting part…and if(a[i]!=b[i]) change it with a[i]>=a[i+1] and run the loop from i=0 to i=n-1
If all values are distinct and input is in descending order only then the answer is “NO”. otherwise answer is “YES”. You are checking second condition with “flag”. But there is a bug for the first condition. You should try “s.size() < n” (it means there is at least one duplicate value). Hopefully it will be accepted then.
my submission gave TLE for test 19 i think
if numbers are in stricktly decreasing order then “NO” otherwise “YES”
For the answer to be “NO”, two conditions should be strictly satisfied
The sequence should have all unique numbers
The sequence should be in sorted in the non-increasing order
If you want your code to work properly use just change to the condition below:-
if(flag==0 && s.size()==n)
cout<<“NO”<<endl;
else
cout<<“YES”<<endl;
Tip: Use “\n” instead of endl for faster printing
Thnx man , just a change in sign woukd have saved me from rewriting the entire code.