#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <utility>
#include <cmath>
#include <numeric>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pb push_back
#define endl "\n"
#define all(x) x.begin(), x.end()
const int M = 200007;
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const double pi = acos(-1);
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
vector <int> v;
int n, k, a[M];
bool vist[M];
int solve(int sum)
{
int l = 1, r = n + k;
while(l < r){
if(a[l] + a[r] == sum){
++l;
--r;
}
else if(a[l] + a[r] > sum){
v.pb(r);
--r;
}
else{
v.pb(l);
++l;
}
}
if(l == r) v.pb(l);
return ((int)v.size() == k);
}
int main()
{
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin >> n >> k;
for(int i = 1; i <= n + k; ++i) cin >> a[i];
sort(a + 1, a + n + k + 1);
bool res = 0;
for(int i = 1; i <= k + 1; ++i){
for(int j = n; j >= max(i, n - k - 1); --j){
v.clear();
res = solve(a[i] + a[j]);
if(res) break;
}
if(res) break;
}
for(auto i : v) vist[i] = 1;
for(int i = 1; i <= n + k; ++i) if(!vist[i]) cout << a[i] << " ";
cout << endl;
return 0;
}
// Don't forget special cases. (n = 1?)
// Look for the constraints. (Runtime array? overflow?)
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
332 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
484 KB |
Output is correct |
2 |
Incorrect |
21 ms |
1996 KB |
Unexpected end of file - int32 expected |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
33 ms |
3068 KB |
Output is correct |
2 |
Correct |
27 ms |
2324 KB |
Output is correct |
3 |
Incorrect |
21 ms |
1996 KB |
Unexpected end of file - int32 expected |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Incorrect |
4 ms |
204 KB |
Unexpected end of file - int32 expected |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Incorrect |
2 ms |
332 KB |
Unexpected end of file - int32 expected |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Incorrect |
391 ms |
1996 KB |
Unexpected end of file - int32 expected |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Execution timed out |
3087 ms |
2036 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |