#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ii pair<ll,ll>
#define fi first
#define se second
#define endl '\n'
#define puf push_front
#define pof pop_front
#define pub push_back
#define pob pop_back
#define rep(x,s,e) for (auto x=s-(s>e);x!=e-(s>e);s<e?x++:x--)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int) (x).size()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int n,k;
int arr[160005];
vector<int> v;
int main(){
cin.tie(0);
cout.tie(0);
cin.sync_with_stdio(false);
cin>>n>>k;
rep(x,0,n+k) cin>>arr[x];
int l=n,r=n+k+k;
rep(x,0,n+k){
l--,r--;
if (r<x) break;
rep(y,max(x+1,l),min(r,n+k)+1){
//cout<<x<<" "<<y<<endl;
v.pub(arr[x]+arr[y]);
}
}
sort(all(v));
int val;
while (true){
int temp=v.back();
int cnt=0;
while (!v.empty() && v.back()==temp){
v.pob();
cnt++;
}
if (cnt>=n/2){
val=temp;
break;
}
}
vector<int> ans;
r=n+k-1;
rep(x,0,n+k){
while (arr[x]+arr[r]>val) r--;
if (arr[x]+arr[r]==val){
ans.pub(arr[x]);
ans.pub(arr[r]);
r--;
if (sz(ans)==n) break;
}
}
sort(all(ans));
for (auto &it:ans) cout<<it<<" "; cout<<endl;
}
Compilation message
tabletennis.cpp: In function 'int main()':
tabletennis.cpp:78:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
78 | for (auto &it:ans) cout<<it<<" "; cout<<endl;
| ^~~
tabletennis.cpp:78:36: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
78 | for (auto &it:ans) cout<<it<<" "; cout<<endl;
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
844 KB |
Output is correct |
2 |
Correct |
55 ms |
3900 KB |
Output is correct |
3 |
Correct |
55 ms |
4036 KB |
Output is correct |
4 |
Correct |
55 ms |
3916 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
54 ms |
5452 KB |
Output is correct |
2 |
Correct |
67 ms |
5452 KB |
Output is correct |
3 |
Correct |
54 ms |
5500 KB |
Output is correct |
4 |
Correct |
61 ms |
5444 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
2 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
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 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
3 ms |
716 KB |
Output is correct |
3 |
Correct |
5 ms |
716 KB |
Output is correct |
4 |
Correct |
3 ms |
716 KB |
Output is correct |
5 |
Correct |
3 ms |
716 KB |
Output is correct |
6 |
Correct |
3 ms |
716 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
360 ms |
17456 KB |
Output is correct |
3 |
Correct |
280 ms |
17444 KB |
Output is correct |
4 |
Correct |
200 ms |
17552 KB |
Output is correct |
5 |
Correct |
272 ms |
17452 KB |
Output is correct |
6 |
Correct |
193 ms |
17356 KB |
Output is correct |
7 |
Correct |
203 ms |
17436 KB |
Output is correct |
8 |
Correct |
198 ms |
17392 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
976 KB |
Output is correct |
2 |
Execution timed out |
3066 ms |
263632 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |