#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define fi first
#define se second
#define all(m) (m).begin(), (m).end()
#define rall(m) (m).rbegin(), (m).rend()
#define vec vector
#define sz(a) (int) (a).size()
#define mpp make_pair
#define mtt make_tuple
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef tuple <int, int, int> tui;
template <typename T> bool umin(T &a, T b) { return a > b ? a = b, 1 : 0; }
template <typename T> bool umax(T &a, T b) { return a < b ? a = b, 1 : 0; }
mt19937 rng((uint64_t) new char);
int solve(){
int n, k;
cin >> n >> k;
int z = n + k;
vec <int> a(z);
for (auto &i: a) cin >> i;
set <int> s(all(a));
if (n < k){
for (int i = 0; i < z; ++i){
for (int j = i + 1; j < z; ++j){
int x = a[i] + a[j];
int cnt = 0;
for (int l = 0; l < z; ++l){
cnt += s.count(x - a[l]);
}
if (cnt >= n){
vec <int> ans;
for (int k = 0; k < z; ++k){
if (s.count(x - a[k]) && n){
ans.push_back(a[k]);
ans.push_back(x - a[k]);
s.erase(a[k]), n -= 2;
}
}
sort(all(ans));
for (auto &k: ans) cout << k << " ";
return 0;
}
}
}
}
for (int it = 0; it < 200; ++it){
int x = a[rng() % n] + a[rng() % n];
int cnt = 0;
for (int l = 0; l < z; ++l){
cnt += s.count(x - a[l]);
}
if (cnt >= n){
vec <int> ans;
for (int k = 0; k < z; ++k){
if (s.count(x - a[k]) && n){
ans.push_back(a[k]);
ans.push_back(x - a[k]);
s.erase(a[k]), n -= 2;
}
}
sort(all(ans));
for (auto &k: ans) cout << k << " ";
return 0;
}
}
return 0;
}
signed main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int tst = 1; //cin >> tst;
while(tst--) solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
10 ms |
340 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
222 ms |
1236 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1923 ms |
7964 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Unexpected end of file - int32 expected |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
11 ms |
340 KB |
Unexpected end of file - int32 expected |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1985 ms |
7892 KB |
Unexpected end of file - int32 expected |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Incorrect |
2054 ms |
7912 KB |
Unexpected end of file - int32 expected |
3 |
Halted |
0 ms |
0 KB |
- |