# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
366231 | Ahmad_Hasan | Table Tennis (info1cup20_tabletennis) | C++17 | 3075 ms | 12580 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define int long long
/**
|||||||||| ||||| ||||| ||||||||||
||||||||||||| ||||| ||||| |||||
|||| |||||| ||||| ||||| |||||
||||||||||||||||| ||||||||||||||| ||||||||||
||||||||||||||||||| ||||||||||||||| |||||
||||| ||||| ||||| ||||| |||||
||||| ||||| ||||| ||||| ||||||||||
AHMED;HASSAN;SAEED;
*/
using namespace std;
int32_t main()
{
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int n,k;
cin>>n>>k;
vector<int>v(n+k);
unordered_map<int,int >mp,mp2;
int nn=n+k;
for(int i=0;i<nn;i++){
cin>>v[i];
}
vector<vector<pair<int,int> > >pos((k+5)*(k+5));
int cr=1;
for(int i=0;i<nn&&i<k+2;i++){
for(int j=nn-1;j>=0&&(nn-1-j)<=k+2;j--){
if(!mp[v[i]+v[j]]){
mp[v[i]+v[j]]=cr++;
}
}
}
int mxi=0;
for(unordered_map<int,int>::iterator it=mp.begin();it!=mp.end();it++){
for(int i=0;i<nn;i++){
vector<int>::iterator it2=lower_bound(v.begin(),v.end(),(it->first)-v[i]);
if(it2==v.end()||*it2!=(it->first)-v[i])continue;
int vl=it2-v.begin();
if(vl>i){
pos[it->second].push_back({i,vl});
}
}
}
/**
for(int i=0;i<pos.size();i++){
for(int j=0;j<pos[i].size();j++){
cout<<pos[i][j].first<<'-'<<pos[i][j].second<<' ';
}
cout<<'\n';
}*/
for(int i=0;i<pos.size();i++)
if(pos[i].size()>pos[mxi].size())
mxi=i;
vector<int>ans(n);
int l=0,r=n-1;
for(int i=0;i<pos[mxi].size()&&i<n/2;i++){
ans[l]=(v[pos[mxi][i].first]);
ans[r]=(v[pos[mxi][i].second]);
l++; r--;
}
for(int i=0;i<ans.size();i++)
cout<<ans[i]<<' ';
return 0;
}
/**
4 3
100000000000 200000000000 300000000000 400000000000 800000000000 1000000000000 2000000000000
*/
Compilation message (stderr)
# | 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... |