https://codeforces.com/contest/1420/problem/A
贪心考虑极端情况,也就是完全从大到小的,手动模拟发现始终比题目的yes条件少一个,那么其他情况只要有一个地方和这个最劣解不同,就会至少有+1的优化,那么就是Yes
#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<map>
#include<set>
#include<cstdio>
#include<algorithm>
#define debug(a) cout<<#a<<"="<<a<<endl;
using namespace std;
const int maxn=5e4+100;
typedef long long LL;
LL a[maxn];
int main(void)
{
cin.tie(0);std::ios::sync_with_stdio(false);
LL t;cin>>t;
while(t--)
{
LL n;cin>>n;
for(LL i=1;i<=n;i++) cin>>a[i];
LL sum=0;
for(LL i=1;i<n;i++)
{
if(a[i]>a[i+1]) sum++;
}
if(sum==n-1) cout<<"NO"<<endl;
else cout<<"YES"<<endl;
}
return 0;
}