其他分享
首页 > 其他分享> > Codeforces Round #746 (Div. 2)

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

标签:return,746,int,scanf,Codeforces,solve,printf,Div
来源: https://blog.csdn.net/qq_52006128/article/details/120604747