This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/*input
4 2
1 2 3 4 5 6
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_sett;
//order_of_key #of elements less than x
// find_by_order kth element
typedef long long int ll;
#define ld double
#define pii pair<ll,ll>
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memsett(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
const ll maxn=2e5+5;
const ll maxlg=__lg(maxn)+2;
const ll INF64=4e17;
const int INF=0x3f3f3f3f;
const ll MOD2=3006703054056749LL;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld eps=1e-4;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
ll mult(ll a,ll b){
return ((a%MOD)*(b%MOD))%MOD;
}
ll mypow(ll a,ll b){
ll res=1;
while(b){
if(b&1) res=mult(res,a);
a=mult(a,a);
b/=2;
}
return res;
}
int arr[maxn];
int ar[maxn],l[maxn],r[maxn];
int32_t main(){
ios::sync_with_stdio(false),cin.tie(0);
int n,k;
cin>>n>>k;
REP(i,n+k) cin>>arr[i];
REP(i,k+1){
for(int j=n+k-1;j>=n+i-1;j--){
int pp=0;
int s=arr[i]+arr[j];
int l=i,r=j;
vector<int> ans;
int bad=0;
while(l<r){
int sm=arr[l]+arr[r];
if(sm==s){
ans.pb(arr[l]),ans.pb(arr[r]);
++l,--r;
if(sz(ans)==n){
sort(ALL(ans));
for(auto x:ans) cout<<x<<' ';
return 0;
}
}
else if(sm<s) ++l,++bad;
else --r,++bad;
if(bad>k) break;
}
}
}
}
Compilation message (stderr)
tabletennis.cpp: In function 'int32_t main()':
tabletennis.cpp:57:17: warning: unused variable 'pp' [-Wunused-variable]
57 | int pp=0;
| ^~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |