# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
845921 | Piokemon | Table Tennis (info1cup20_tabletennis) | C++17 | 138 ms | 13316 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;
typedef long long int ll;
constexpr int N = 15e4;
ll a[N+9+500];
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n,k;
cin >> n >> k;
for (int x=1;x<=n+k;x++) cin >> a[x];
map<ll,bool>spr;
ll znal=-1;
for (int x=1;x<=k+1;x++){
for (int y=max(x+1,n);y<=n+k;y++){
if (spr[a[x]+a[y]])continue;
ll cel=a[x]+a[y];
spr[cel]=1;
int l,r,pomin;
l = 1;
r = n+k;
pomin = 0;
while(l<r){
if (pomin>k) break;
if (a[l]+a[r]<cel){l++;pomin++;}
else if (a[l]+a[r]==cel){l++;r--;}
else {r--;pomin++;}
}
if (l==r)pomin++;
if (pomin<=k){
znal=cel;
break;
}
}
if (znal!=-1) break;
}
vector<int> odp;
int l,r;
l = 1;
r = n+k;
while(l<r){
if (odp.size()==n)break;
if (a[l]+a[r]<znal) l++;
else if (a[l]+a[r]==znal){
odp.push_back(a[l]);
odp.push_back(a[r]);
l++;
r--;
}
else r--;
}
sort(odp.begin(),odp.end());
for (int x:odp) cout << x << ' ';
}
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... |