#include <bits/stdc++.h>
using namespace std;
const int N = 160003;
const int K = 403;
int n, k;
int a[N];
void solve(int lo, int hi, int sum)
{
vector < int > res;
int cur = 1;
res.push_back(a[lo]), res.push_back(a[hi]);
int i = lo + 1, j = hi - 1;
while (i < j && cur < n / 2)
{
if (a[i] + a[j] > sum) j--;
if (a[i] + a[j] < sum) i++;
if (a[i] + a[j] == sum)
{
cur++;
res.push_back(a[i]);
res.push_back(a[j]);
i++; j--;
}
}
if (cur == n / 2)
{
sort(res.begin(), res.end());
for (int u : res)
cout << u << " ";
exit(0);
}
return;
}
int main()
{
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> n >> k;
int m = n + k;
for (int i = 1; i <= m; i++)
cin >> a[i];
sort(a + 1, a + m + 1);
for (int i = 1; i <= k + 1; i++)
{
for (int j = i + n - 1; j <= m; j++)
{
solve(i, j, a[i] + a[j]);
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
812 KB |
Output is correct |
2 |
Correct |
45 ms |
3176 KB |
Output is correct |
3 |
Correct |
41 ms |
3176 KB |
Output is correct |
4 |
Correct |
43 ms |
3176 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
42 ms |
3176 KB |
Output is correct |
2 |
Correct |
42 ms |
3176 KB |
Output is correct |
3 |
Correct |
42 ms |
3176 KB |
Output is correct |
4 |
Correct |
43 ms |
3176 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
2 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
2 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
2 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
185 ms |
3304 KB |
Output is correct |
3 |
Correct |
43 ms |
3176 KB |
Output is correct |
4 |
Correct |
65 ms |
3096 KB |
Output is correct |
5 |
Correct |
46 ms |
3176 KB |
Output is correct |
6 |
Correct |
61 ms |
3176 KB |
Output is correct |
7 |
Correct |
61 ms |
3168 KB |
Output is correct |
8 |
Correct |
44 ms |
3168 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
492 KB |
Output is correct |
2 |
Execution timed out |
3063 ms |
1004 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |