#include "bits/stdc++.h"
#define ll long long
using namespace std;
const ll mod = 1000000007;
int b[150001], cnt[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;
if(k > 2)
return 0;
vector<int> v;
set<int> ss;
for(int i = 0; i < n + k; i++) {
int x;
cin >> x;
ss.insert(x);
v.push_back(x);
}
map<int, int> c;
int o = 1;
for(int i : ss)
c[i] = o++;
for(int i = 0; i < n + k; i++)
cnt[c[v[i]]]++;
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;
for(int i = 0; i < n + k; i++) {
if(cnt[c[v[i]]] - b[c[v[i]]] && x - v[i] >= 0 && cnt[c[x - v[i]]] - b[c[x - v[i]]]) {
b[c[v[i]]]++, b[c[x - v[i]]]++;
y += 2;
if(y == n)
break;
}
}
if(y >= n) {
set<int> ans;
for(int i = 0; i < n + k; i++) {
if(b[c[v[i]]]) {
b[c[v[i]]]--;
ans.insert(v[i]);
}
}
for(int i : ans)
cout << i << " ";
return 0;
}
for(int i = 0; i < n + k; i++)
b[c[v[i]]] = 0;
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
724 KB |
Output is correct |
2 |
Correct |
2 ms |
596 KB |
Output is correct |
3 |
Correct |
2 ms |
596 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
22 ms |
3532 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
353 ms |
36536 KB |
Output is correct |
2 |
Correct |
200 ms |
24636 KB |
Output is correct |
3 |
Correct |
595 ms |
56724 KB |
Output is correct |
4 |
Correct |
202 ms |
24716 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |