#include <bits/stdc++.h>
#define int long long
#define endl "\n"
using namespace std;
vector <int> v, sp, resp;
map <int, int> mm;
int n, k, val;
int test(int s)
{
int c = 0;
for(auto i : v)
{
if(mm.find(s - i) != mm.end()) c++;
}
if(c < n) return 0;
return 1;
}
main()
{
cin >> n >> k;
int a1 = 1e9, a2 = -1, mn;
for(int i = 0; i < n + k; i++) {int aux; cin >> aux; v.push_back(aux); mm[aux] = 1; a1 = min(a1, aux); a2 = max(a2, aux); mn = a1 + a2;}
sort(v.begin(), v.end());
for(int i = 0; i < n + k; i++)
{
if(i == 0) sp.push_back(v[i]);
else sp.push_back(sp[i - 1] + v[i]);
}
int sss = 0;
mn = v[0] + v[n - 1];
int ini = max(mn, (2LL * sp[n - 1])/n);
mn = v[n + k - 1] + v[k];
int fim = min(mn, (2LL * (sp[n + k - 1] - sp[k - 1]))/n);
for(int i = ini; i <= fim; i++)
{
if(test(i) && !sss)
{
int c = 0;
for(auto j : v)
{
if(c == n) break;
if(mm.find(i - j) != mm.end())
{
sss = 1;
c+=2;
resp.push_back(j);
resp.push_back(i - j);
}
}
}
}
sort(resp.begin(), resp.end());
for(auto i : resp) cout << i << " ";
}
Compilation message
tabletennis.cpp:18:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
18 | main()
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
253 ms |
468 KB |
Output is correct |
2 |
Execution timed out |
3088 ms |
468 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3087 ms |
2000 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3090 ms |
13904 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3070 ms |
212 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3053 ms |
212 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3063 ms |
212 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3077 ms |
212 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3075 ms |
212 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |