| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1319449 | nnargiz | Table Tennis (info1cup20_tabletennis) | C++20 | 0 ms | 0 KiB |
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define int long long
using namespace __gnu_pbds;
using namespace std;
const int mod = 1e6 + 3;
const int inf = 1e9;
const int maxx = 3e6 + 5;
const int lg = 26;
typedef tree <int, null_type, less_equal <int>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset;
void solve () {
int n, k, sum = 0, idx1 = -1, idx2 = -1;
cin >> n >> k;
vector <int> a(n + k);
for (int i = 0; i < n + k; i++) {
cin >> a[i];
sum += a[i];
}
if (sum % 2) {
for (int i = 0; i < n + k; i++) {
if (a[i] % 2 && idx == -1) {
idx1 = i;
idx2 = i;
break;
}
if (a[i] % 2) {
idx2 = i;
}
}
}
// 1 2 3 4 7
// 1 3
// 3 6 7 8 9
if (a[1] - a[0] > a[n - 1] - a[n - 2]) {
if (sum % 2 == 0) {
for (int i = 1; i <= n; i++) {
cout << a[i] << ' ';
}
}
else {
for (int i = 0; i < idx2; i++) {
cout << a[i] << ' ';
}
for (int i = idx2 + 1; i <= n; i++) {
cout << a[i] << ' ';
}
}
}
else {
if (sum % 2 == 0) {
for (int i = 0; i < n; i++) {
cout << a[i] << ' ';
}
}
else {
for (int i = 0; i < idx2; i++) {
cout << a[i] << ' ';
}
for (int i = idx2 + 1; i <= n; i++) {
cout << a[i] << ' ';
}
}
}
}
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t = 1;
//cin >> t;
while (t--) {
solve();
}
}
