Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- int main()
- {
- int n,k,p,x,y;
- cin >> n >> k >> p >> x >> y; //reading
- int goods=0,sum=0; //goods: number of ai's, where ai>=y sum: sum of ai's
- vector<int> a; a.reserve(n); //the given tests
- for(int i=0;i<k;++i)
- {
- int ai; //the current test
- cin >> ai; //reading
- a.push_back(ai); //adding into the vector
- sum+=ai; //...
- if(y<=ai) goods++; //...
- }
- vector<int> ans; //the vector, where we hold our answers
- while(goods<(n-goods)) //In the Editorial, the first condition
- {
- ans.push_back(y);
- goods++;
- sum+=y;
- }
- if( ans.size()+a.size()>n ) //If we have to write more than n tests to satisfy the condtition, then we're wrong.
- {
- cout << "-1\n";
- return 0;
- }
- while(ans.size()+a.size()<n) //First condition: ok, then fill the remaining space with ones.
- {
- ans.push_back(1);
- sum++;
- }
- if( sum > x ) //Second Condition
- {
- cout << "-1\n";
- return 0;
- }
- for(auto i:ans) //Simply print the answer to the problem
- {
- cout << i << " ";
- }
- cout << "\n";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment