#include "bits/stdc++.h"
#define ll long long
using namespace std;
const ll mod = 1000000007;
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;
set<int> ss;
for(int i = 0; i < n + k; i++) {
int x;
cin >> x;
ss.insert(x);
v.push_back(x);
}
sort(v.begin(), v.end());
map<int, int> mp;
for(int i = 0; i < n + k; i++)
mp[v[i]] = i + 1;
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 && y < n; i++) {
if(mp[v[i]] && mp[x - v[i]])
y += 2;
}
if(y >= n) {
set<int> ans;
for(int i = 0; i < n + k; i++) {
if(mp[v[i]] && mp[x - v[i]]) {
ans.insert(v[i]);
ans.insert(x - v[i]);
}
}
for(int i : ans)
cout << i << " ";
return 0;
}
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
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 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
20 ms |
3412 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
265 ms |
35524 KB |
Output is correct |
2 |
Correct |
176 ms |
23492 KB |
Output is correct |
3 |
Correct |
419 ms |
55600 KB |
Output is correct |
4 |
Correct |
183 ms |
23428 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
524 KB |
Output is correct |
2 |
Correct |
314 ms |
14928 KB |
Output is correct |
3 |
Correct |
1 ms |
468 KB |
Output is correct |
4 |
Correct |
53 ms |
6252 KB |
Output is correct |
5 |
Correct |
2 ms |
468 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
36 ms |
1996 KB |
Output is correct |
3 |
Correct |
2 ms |
596 KB |
Output is correct |
4 |
Correct |
15 ms |
3500 KB |
Output is correct |
5 |
Correct |
2 ms |
596 KB |
Output is correct |
6 |
Incorrect |
18 ms |
1364 KB |
Unexpected end of file - int32 expected |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Execution timed out |
3030 ms |
229916 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
15 ms |
4052 KB |
Output is correct |
2 |
Execution timed out |
3068 ms |
234908 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |