This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#ifdef local
#define debug(a...) qqbx(#a, a)
template <typename ...T> void qqbx(const char *s, T ...a) {
int cnt = sizeof...(T);
((std::cerr << "\033[1;32m(" << s << ") = (") , ... , (std::cerr << a << (--cnt ? ", " : ")\033[0m\n")));
}
#define pary(a...) danb(#a, a)
template <typename T> void danb(const char *s, T L, T R) {
std::cerr << "\033[1;32m[ " << s << " ] = [ ";
for (int f = 0; L != R; ++L) std::cerr << (f++ ? " " : "") << *L;
std::cerr << " ]\033[0m\n";
}
#else
#define debug(...) ((void)0)
#define pary(...) ((void)0)
#endif // local
#define all(v) begin(v),end(v)
#define pb emplace_back
using namespace std;
using ll = int64_t;
const int inf = 1e9, MOD = 1000000007, maxn = 1 << 18, maxLg = 18;
signed main() {
ios_base::sync_with_stdio(0), cin.tie(0);
int n, k;
cin >> n >> k;
vector<int> a[2];
ll sum = 0;
for (int i = 0; i < n + k; i++) {
int x;
cin >> x;
a[x & 1].emplace_back(x);
sum += x;
}
if (sum & 1) {
a[1].pop_back();
--k;
}
while (k >= 2 && a[1].size() >= 2) {
a[1].pop_back();
a[1].pop_back();
k -= 2;
}
while (k) {
a[0].pop_back();
--k;
}
vector<int> ans;
for (int i = 0; i < 2; i++)
for (int x: a[i])
ans.emplace_back(x);
sort(all(ans));
for (int x: ans)
cout << x << ' ';
cout << '\n';
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |