Codeforces Round #643 (Div. 2) D——Game With Array

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define P pair<int,int>
#define mk make_pair
const int N = 2e3 + 10;
void solve()
{
    //构建长度为n的序列,和为s
    //能否找到一个子序列 和为k或者s-k
    int n,s,flag;
    cin >> n >> s;
    vector<int>v;
    for(int i=1; i<=n-1; i++)
        v.push_back(1);
    v.push_back(s-(n-1));
    //最后一个元素如果大于 元素的个数
    //也就是说 选前n-1个 肯定小于n
    //选上最后一个,就肯定大于 n
    //那么n就凑不出来
    if(s-n+1>n)
        flag = 1;
    else
        flag = 0;
    if(flag)
    {
        cout << "YES\n";
        for(int i=0; i<n; i++)
            cout << v[i] << ' ';
        cout << '\n';
        cout<< n;
    }
    else
        cout<<"NO"<<endl;;


}
int main()
{
    ios::sync_with_stdio(false);
    int T;
    T = 1;
    while(T--)
        solve();
    return 0;
}

猜你喜欢

转载自www.cnblogs.com/QingyuYYYYY/p/12956190.html