# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
424460 | jamezzz | Table Tennis (info1cup20_tabletennis) | C++17 | 375 ms | 33692 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>
using namespace std;
#define sf scanf
#define pf printf
#define fi first
#define se second
#define pb emplace_back
#define all(x) x.begin(),x.end()
int n,k,v;
vector<int> s,ans;
map<int,int> cnt;
int main(){
sf("%d%d",&n,&k);
n+=k;
for(int i=0;i<n;++i){
sf("%d",&v);
s.push_back(v);
}
sort(all(s));
if(n>=4*k){
for(int i=0;i<2*k;++i){
for(int j=n-2*k;j<n;++j){
cnt[s[i]+s[j]]+=1;
}
}
}
else{
for(int i=0;i<n;++i){
for(int j=i+1;j<n;++j)cnt[s[i]+s[j]]=k;
}
}
for(auto it:cnt){
if(it.se>=k){
ans.clear();
int cr=n-1;
for(int i=0;i<n;++i){
if(s[i]>=it.fi-s[i])break;
while(it.fi-s[i]<s[cr])--cr;
if(it.fi-s[i]==s[cr]){
ans.pb(s[i]);
ans.pb(it.fi-s[i]);
--cr;
}
if(ans.size()==n-k)break;
}
if(ans.size()==n-k)break;
}
}
sort(all(ans));
for(int x:ans)pf("%d ",x);
pf("\n");
}
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... |