#include <bits/stdc++.h>
using namespace std;
#define sz(x) (int) (x).size()
#define all(x) (x).begin(), (x).end()
#define show(x) cerr << #x << " is " << x << endl;
#define show2(x,y) cerr << #x << " is " << x << " " << #y << " is " << y << endl;
#define show3(x,y,z) cerr << #x << " is " << x << " " << #y << " is " << y << " " << #z << " is " << z << endl;
#define tern(cond, a, b) (cond ? a : b)
typedef long long lint;
typedef pair<lint,lint> ii;
int n, K;
vector<int> arr;
unordered_map<int,int> M;
int main(){
ios_base::sync_with_stdio(false); cin.tie(0);
M.reserve(4096);
M.max_load_factor(0.25);
cin >> n >> K;
n += K;
arr.resize(n);
for(int i = 0;i < n;i++) cin >> arr[i];
for(int i = K+1;i <= n-K-1;i++){
int other = n-i;
for(int j = max(other-K-5,0);j <= min(n-1, other+K+5);j++){
if(i != j) M[arr[i]+arr[j]]++;
}
}
for(int s = 0;s <= K+1;s++){
for(int e = n-1;e >= n-K-1;e--){
if(s + (n-1)-e > K) continue;
int str = arr[s]+arr[e];
vector<int> ans;
for(int i = s;i < K+1;i++){
auto it = lower_bound(all(arr), str-arr[i]);
if(it == arr.end()) continue;
if(*it == str-arr[i] and arr[i] != str-arr[i]) ans.push_back(arr[i]);
}
for(int i = n-K;i <= e;i++){
auto it = lower_bound(all(arr), str-arr[i]);
if(it == arr.end()) continue;
if(*it == str-arr[i] and arr[i] != str-arr[i]) ans.push_back(arr[i]);
}
if(sz(ans) + M[str] == n-K){
ans.clear();
for(int i = s;i <= e;i++){
auto it = lower_bound(all(arr), str-arr[i]);
if(it == arr.end()) continue;
if(*it == str-arr[i] and arr[i] != str-arr[i]) ans.push_back(arr[i]);
}
for(int x : ans) cout << x << " ";
return 0;
}
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
2 ms |
332 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
808 KB |
Output is correct |
2 |
Correct |
147 ms |
8340 KB |
Output is correct |
3 |
Correct |
141 ms |
8296 KB |
Output is correct |
4 |
Correct |
124 ms |
8472 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
95 ms |
3104 KB |
Output is correct |
2 |
Correct |
87 ms |
5268 KB |
Output is correct |
3 |
Correct |
86 ms |
3104 KB |
Output is correct |
4 |
Correct |
83 ms |
5324 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Incorrect |
11 ms |
844 KB |
Unexpected end of file - int32 expected |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
0 ms |
332 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
3 ms |
332 KB |
Output is correct |
3 |
Correct |
13 ms |
4968 KB |
Output is correct |
4 |
Correct |
3 ms |
844 KB |
Output is correct |
5 |
Correct |
3 ms |
332 KB |
Output is correct |
6 |
Correct |
3 ms |
332 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
716 ms |
20816 KB |
Output is correct |
3 |
Correct |
350 ms |
20756 KB |
Output is correct |
4 |
Correct |
153 ms |
3636 KB |
Output is correct |
5 |
Correct |
296 ms |
20352 KB |
Output is correct |
6 |
Correct |
185 ms |
3092 KB |
Output is correct |
7 |
Correct |
185 ms |
3608 KB |
Output is correct |
8 |
Correct |
181 ms |
3372 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
412 KB |
Output is correct |
2 |
Execution timed out |
3058 ms |
327544 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |