Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define NguyenDangQuan the_author
- #include <algorithm>
- #include <iostream>
- #include <string>
- #include <vector>
- #include <queue>
- #include <stack>
- #include <set>
- #include <map>
- #include <cmath>
- #include <climits>
- #include <iomanip>
- #define all(x) x.begin(),x.end()
- #define mset(x, i) memset(x,i,sizeof(x))
- #define elif else if
- #define heap priority_queue
- #define fi first
- #define se second
- #define pb push_back
- #define ld long double
- #define ll long long
- #define ull unsigned long long
- #define task "cocktail"
- using namespace std;
- int typetest;
- inline void fastIOfileinput(){
- ios_base:: sync_with_stdio(0);
- cin.tie(0);
- cout.tie(0);
- if(fopen(task".inp", "r")){
- freopen(task".inp", "r", stdin);
- freopen(task".out", "w", stdout);
- }
- if(fopen(task".in", "r")){
- freopen(task".in", "r", stdin);
- freopen(task".out", "w", stdout);
- }
- typetest = 0;
- }
- const int N = 1e3 + 2;
- int n, k;
- int a[N];
- queue<int> s;
- bool ck[2001];
- int trace[2001];
- int ans[2001];
- inline void Enter(){
- cin >> n >> k;
- for(int i = 1; i <= n; ++i)
- cin >> a[i], a[i] -= k;
- }
- void traces(int i){
- if(i - a[trace[i]] == 0){
- ++ans[trace[i]];
- return;
- }
- ++ans[trace[i]];
- traces(i - a[trace[i]]);
- }
- inline void solve(){
- for(int i = 1; i <= n; ++i)
- if(a[i] > -1){
- s.push(a[i]);
- trace[a[i]] = i;
- ck[a[i]] = 1;
- }
- bool ok = 0;
- while(!s.empty()){
- int c = s.front();
- s.pop();
- if(c == 0)
- {ok = 1; break;}
- for(int i = 1; i <= n; ++i)
- if(c + a[i] <= 2000 && c + a[i] > -1 && !ck[c + a[i]]){
- s.push(c + a[i]);
- ck[c + a[i]] = 1;
- trace[c + a[i]] = i;
- }
- }
- if(!ok) cout << "NO";
- else{
- cout << "YES\n";
- traces(0);
- for(int i = 1; i <= n; ++i)
- cout << ans[i] << " ";
- }
- }
- signed main(){
- fastIOfileinput();
- if(typetest){
- int t;
- cin >> t;
- while(t--){
- Enter();
- solve();
- }
- }
- else{
- Enter();
- solve();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement