Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <vector>
- #include <iostream>
- using namespace std;
- void no()
- {
- cout<<"no"<<endl;
- exit(0);
- }
- int main(int argc, char* argv[])
- {
- int n, k;
- scanf("%d%d", &n, &k);
- vector<int> a, b;
- for (int i = 0; i < n; i++)
- {
- int x;
- scanf("%d", &x);
- if (x % 2 == 1) a.push_back(x);
- else b.push_back(x);
- }
- if (a.size() == 0) no();
- vector<int> res;
- res.push_back(a.back());
- a.pop_back();
- while(res.size() + 2 <= k && a.size() >= 2)
- {
- res.push_back(a.back());
- a.pop_back();
- res.push_back(a.back());
- a.pop_back();
- }
- while(res.size() + 1 <= k && b.size() >= 1)
- {
- res.push_back(b.back());
- b.pop_back();
- }
- if (res.size() != k) no();
- printf("yes\n");
- for (int i = 0; i < res.size(); i++)
- {
- printf("%d ", res[i]);
- }
- printf("\n");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement