#include "bits/stdc++.h"
#define ll long long
using namespace std;
const ll mod = 1000000007;
int b[150001];
signed main () {
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
// freopen("cowland.in","r",stdin);
// freopen("cowland.out","w",stdout);
int n, k;
cin >> n >> k;
vector<int> v;
for(int i = 0; i < n + k; i++) {
int x;
cin >> x;
v.push_back(x);
}
sort(v.begin(), v.end());
set<int> s;
for(int i = 0; i <= k; i++) {
int j = n + k - 1;
while(i < j && i + ((n + k) - j - 1) <= k)
s.insert(v[i] + v[j--]);
}
for(int x : s) {
int y = 0, r = 0;
for(int l = 0; l < n + k; l++) {
if(b[l])
continue;
while(r < n + k && l >= r)
r++;
if(r >= n + k)
break;
if(v[l] + v[r] < x) {
while(r < n + k && v[l] + v[r] < x)
r++;
}
else if(v[l] + v[r] > x) {
while(l < r && v[l] + v[r] > x)
r--;
}
if(l < r && r < n + k) {
b[l] = b[r] = 1;
y += 2;
if(y == n)
break;
}
}
if(y == n) {
set<int> ans;
for(int i = 0; i < n + k; i++) {
if(b[i])
ans.insert(v[i]);
}
for(int i : ans)
cout << i << " ";
return 0;
}
for(int i = 0; i < n + k; i++)
b[i] = 0;
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
468 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
8 ms |
1620 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
65 ms |
9976 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
468 KB |
Output is correct |
2 |
Incorrect |
1 ms |
468 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 |
340 KB |
Output is correct |
2 |
Incorrect |
1 ms |
468 KB |
Unexpected end of file - int32 expected |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
61 ms |
8932 KB |
Unexpected end of file - int32 expected |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
19 ms |
4052 KB |
Output is correct |
2 |
Incorrect |
74 ms |
12576 KB |
Unexpected end of file - int32 expected |
3 |
Halted |
0 ms |
0 KB |
- |