#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[12345678];
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[(arr[x]+arr[y])%12345678].pub(arr[x]+arr[y]);
}
}
if (k>=400) return 0;
int val;
rep(x,0,12345678) if (!v[x].empty()){
sort(all(v[x]));
int curr=-1;
int cnt=0;
for (auto it:v[x]){
if (it!=curr) curr=it,cnt=0;
cnt++;
if (cnt>=n/2){
val=curr;
}
}
}
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:79:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
79 | for (auto &it:ans) cout<<it<<" "; cout<<endl;
| ^~~
tabletennis.cpp:79:36: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
79 | for (auto &it:ans) cout<<it<<" "; cout<<endl;
| ^~~~
tabletennis.cpp:68:3: warning: 'val' may be used uninitialized in this function [-Wmaybe-uninitialized]
68 | if (arr[x]+arr[r]==val){
| ^~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
180 ms |
290248 KB |
Output is correct |
2 |
Correct |
193 ms |
290220 KB |
Output is correct |
3 |
Correct |
191 ms |
290244 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
184 ms |
290776 KB |
Output is correct |
2 |
Correct |
249 ms |
294492 KB |
Output is correct |
3 |
Correct |
232 ms |
294636 KB |
Output is correct |
4 |
Correct |
247 ms |
294580 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
232 ms |
294700 KB |
Output is correct |
2 |
Correct |
236 ms |
295100 KB |
Output is correct |
3 |
Correct |
250 ms |
294932 KB |
Output is correct |
4 |
Correct |
234 ms |
295096 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
193 ms |
290496 KB |
Output is correct |
2 |
Correct |
182 ms |
290584 KB |
Output is correct |
3 |
Correct |
185 ms |
290632 KB |
Output is correct |
4 |
Correct |
186 ms |
290628 KB |
Output is correct |
5 |
Correct |
186 ms |
290592 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
176 ms |
290172 KB |
Output is correct |
2 |
Correct |
184 ms |
290196 KB |
Output is correct |
3 |
Correct |
185 ms |
290220 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
177 ms |
290156 KB |
Output is correct |
2 |
Correct |
187 ms |
290444 KB |
Output is correct |
3 |
Correct |
189 ms |
291420 KB |
Output is correct |
4 |
Correct |
189 ms |
290500 KB |
Output is correct |
5 |
Correct |
183 ms |
290360 KB |
Output is correct |
6 |
Correct |
180 ms |
290440 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
180 ms |
290152 KB |
Output is correct |
2 |
Correct |
658 ms |
316208 KB |
Output is correct |
3 |
Correct |
399 ms |
313548 KB |
Output is correct |
4 |
Correct |
341 ms |
308572 KB |
Output is correct |
5 |
Correct |
378 ms |
313484 KB |
Output is correct |
6 |
Correct |
342 ms |
306344 KB |
Output is correct |
7 |
Correct |
350 ms |
308576 KB |
Output is correct |
8 |
Correct |
337 ms |
307712 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
186 ms |
293072 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |