# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
370331 | A_D | Table Tennis (info1cup20_tabletennis) | C++14 | 402 ms | 45016 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
#define ii pair<int,int>
#define F first
#define S second
#define du long double
using namespace std;
const int N=1e6+100;
int a[N];
vector<int> vec;
map<int,int> mp;
vector<int> v;
int n,m,k;
int ok(int v)
{
int l=1,r=m;
while(l<r){
int u=a[l]+a[r];
// cout<<l<<" "<<r<<endl;
// cout<<u<<" "<<v<<endl;
if(u==v){
vec.push_back(a[l]);
vec.push_back(a[r]);
l++;
r--;
}
else if(u<v)l++;
else r--;
}
//for(auto x:vec)cout<<x<<" ";cout<<endl;
while(vec.size()>n)vec.pop_back();
return vec.size()==n;
}
main()
{
cin>>n>>k;
m=n+k;
for(int i=1;i<=m;i++)scanf("%lld",&a[i]);
if(m<=4*k){
for(int i=1;i<=k+1;i++){
for(int j=n;j<=m;j++){
if(ok(a[i]+a[j])){
sort(vec.begin(),vec.end());
for(auto x:vec){
printf("%lld ",x);
}
return 0;
}
else{
vec.clear();
}
}
}
}
else{
for(int i=1;i<=2*k;i++){
for(int j=n-k;j<=m;j++){
mp[a[i]+a[j]]++;
}
}
for(auto x:mp){
if(x.S>=k){
v.push_back(x.F);
}
}
for(auto x:v){
if(ok(x)){
sort(vec.begin(),vec.end());
for(auto y:vec){
printf("%lld ",y);
}
return 0;
}
else{
vec.clear();
}
}
}
}
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... |