Codeforces Round #746 (Div. 2)

原题链接:B. Hemose Shopping

#include <bits/stdc++.h> 
using namespace std;
const int N = 1e5+5;
int a[N],b[N];
bool solve()
{
	int n,x; scanf("%d%d",&n,&x);

	for (int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		b[i]=a[i];
	}
	if (n>=2*x) return true;
	sort(b+1,b+n+1);
	for (int i=n-x+1;i<=x;i++)
		if (a[i]!=b[i]) return false;
	return true;
}
int main()
{
	int t; scanf("%d",&t);
	while (t--)
	{
		if (solve()) printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}
上一篇:装饰者模式


下一篇:Codeforces Round #746 (Div. 2)