题目链接
思路:
将整个序列分成x块,每一块找一个元素出来形成的就是最长递增子序列;而递减序列正好是某一整块元素。
代码:
#include<bits/stdc++.h>
#define int long long
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
const int N=2e6+7;
const int M=2e4+5;
const double eps=1e-8;
const int mod=998244353;
const int inf=0x7fffffff;
const double pi=3.1415926;
using namespace std;
int flag[N];
signed main()
{
IOS;
int t;
cin>>t;
while(t--)
{
int n,x,y;
cin>>n>>x>>y;
int a=sqrt(n),b=n/a;
if(x+y>n+1||x+y<a+b)
{
cout<<"NO"<<endl;
}
else
{
cout<<"YES"<<endl;
vector<int>vt;
for(int i=x;i;i--)
{
int xx = min(n-i+1, y);
for(int j=n-xx+1;j<=n;j++)
{
vt.push_back(j);
}
n-=xx;
}
}
}
return 0;
}