Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- #include <ext/pb_ds/assoc_container.hpp>
- #include <ext/pb_ds/tree_policy.hpp>
- #include <ext/pb_ds/detail/standard_policies.hpp>
- using namespace __gnu_pbds;
- using namespace std;
- #define rep(i,a,b) for(int i = a; i<b; i++)
- #define ll long long
- #define pb push_back
- #define p pop_back
- #define pf push_front
- #define ppf pop_front
- #define all(a) a.begin(),a.end()
- #define rall(a) a.rbegin(),a.rend()
- #define sz(a) (int)a.size()
- #define F first
- #define S second
- #define endl '\n'
- typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
- int main()
- {
- ios::sync_with_stdio(0),cin.tie(0);
- #ifndef ONLINE_JUDGE
- freopen("input.txt","r",stdin);
- freopen("output.txt","w",stdout);
- #endif
- int t;
- cin>>t;
- while(t--){
- int n, x;
- cin>>n>>x;
- vector<int>v(n);
- int s = 0;
- for(int i = 0; i<n; i++) cin>>v[i], s+= v[i];
- if(s==x){
- cout<<"NO"<<endl;
- continue;
- }
- s = 0;
- for(int i=0; i<n-1; i++){
- s +=v[i];
- if(s==x){
- swap(v[i],v[i+1]);
- break;
- }
- }
- cout<<"YES"<<endl;
- for(int i=0;i<n;i++)cout<<v[i]<<' ';
- cout<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement