#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;x!=e;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;
int a=max(x+1,l),b=min(r,n+k)+1;
rep(y,a,b){
//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:80:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
80 | for (auto &it:ans) cout<<it<<" "; cout<<endl;
| ^~~
tabletennis.cpp:80:36: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
80 | for (auto &it:ans) cout<<it<<" "; cout<<endl;
| ^~~~
tabletennis.cpp:69:3: warning: 'val' may be used uninitialized in this function [-Wmaybe-uninitialized]
69 | if (arr[x]+arr[r]==val){
| ^~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
183 ms |
290400 KB |
Output is correct |
2 |
Correct |
180 ms |
290356 KB |
Output is correct |
3 |
Correct |
180 ms |
290244 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
188 ms |
290772 KB |
Output is correct |
2 |
Correct |
237 ms |
294484 KB |
Output is correct |
3 |
Correct |
233 ms |
294452 KB |
Output is correct |
4 |
Correct |
231 ms |
294484 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
234 ms |
294736 KB |
Output is correct |
2 |
Correct |
238 ms |
295072 KB |
Output is correct |
3 |
Correct |
225 ms |
294892 KB |
Output is correct |
4 |
Correct |
230 ms |
295068 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
182 ms |
290500 KB |
Output is correct |
2 |
Correct |
186 ms |
290616 KB |
Output is correct |
3 |
Correct |
187 ms |
290532 KB |
Output is correct |
4 |
Correct |
184 ms |
290496 KB |
Output is correct |
5 |
Correct |
190 ms |
290676 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
185 ms |
290284 KB |
Output is correct |
2 |
Correct |
181 ms |
290220 KB |
Output is correct |
3 |
Correct |
184 ms |
290260 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
202 ms |
290164 KB |
Output is correct |
2 |
Correct |
180 ms |
290416 KB |
Output is correct |
3 |
Correct |
187 ms |
291288 KB |
Output is correct |
4 |
Correct |
196 ms |
290576 KB |
Output is correct |
5 |
Correct |
184 ms |
290388 KB |
Output is correct |
6 |
Correct |
181 ms |
290508 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
197 ms |
290116 KB |
Output is correct |
2 |
Correct |
593 ms |
316364 KB |
Output is correct |
3 |
Correct |
383 ms |
313660 KB |
Output is correct |
4 |
Correct |
321 ms |
308592 KB |
Output is correct |
5 |
Correct |
369 ms |
313576 KB |
Output is correct |
6 |
Correct |
326 ms |
306444 KB |
Output is correct |
7 |
Correct |
307 ms |
308508 KB |
Output is correct |
8 |
Correct |
305 ms |
307756 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
194 ms |
293060 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |