# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
377598 | keta_tsimakuridze | Table Tennis (info1cup20_tabletennis) | C++14 | 522 ms | 46044 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 f first
#define int long long
#define s second
using namespace std;
const int N=2e5+5,mod=1e9+7;
int t,a[N],n,k;
vector<int>v,Ans,ans;
map<int,int>fix;
string s;
main(){
cin>>n>>k;
n+=k;
for(int i=1;i<=n;i++){
cin>>a[i];
}
Ans.resize(n);
if(n>=4*k)
for(int i=1;i<=2*k;i++){
for(int j=n;j>=n-2*k+1;j--){
fix[a[i]+a[j]]++;
if(fix[a[i]+a[j]]==k) v.push_back(a[i]+a[j]);
}
}
else for(int i=0;i<=k;i++){
for(int j=n;j>=n-k+i;j--){
v.push_back(a[i+1]+a[j]);
}
}
for(int i=0;i<v.size();i++){
int sum = v[i];
ans.clear();
int l=1,r=n;
while(l<r) {
if(a[l]+a[r]==sum){
ans.push_back(a[l]);
ans.push_back(a[r]);
l++;
r--;
}
else if(a[l]+a[r]<sum) l++;
else r--;
}
if(ans.size()>=n-k){
Ans=ans;
}
}
sort(Ans.begin(),Ans.end());
for(int i=0;i<(n-k)/2;i++){
cout<<Ans[i]<<" ";
}
for(int i=(int)Ans.size()-(n-k)/2;i<=Ans.size()-1;i++){
cout<<Ans[i]<<" ";
}
}
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... |