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;
}