# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
518358 | Ronin13 | Table Tennis (info1cup20_tabletennis) | C++14 | 417 ms | 43616 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 ll long long
#define ull unsigned ll
#define pb push_back
#define f first
#define s second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define epb emplace_back
#define inf 1e9+1
#define linf 1e18+11
using namespace std;
map<ll,int>used;
int main(){
int n;cin>>n;
int k;cin>>k;
n+=k;
int a[n+1];
for(int i=1;i<=n;i++)cin>>a[i];
vector<int>vec;
if(n>=4*k){
for(int i=1;i<=2*k+1;i++){
for(int j=n;j>=n-2*k;j--){
int x=a[i]+a[j];
used[x]++;
if(used[x]==k)vec.pb(x);
}
}
}
else{
for(int i=1;i<=k+1;i++){
for(int j=n;j>=n-k;j--){
int x=a[i]+a[j];
vec.pb(x);
}
}
}
for(int to:vec){
int l=1,r=n;
vector<int>ans;
while(l<r){
if(ans.size()==(n-k))break;
if(a[l]+a[r]==to){
ans.pb(a[l]);
ans.pb(a[r]);
l++;
r--;
continue;
}
if(a[l]+a[r]>to){
r--;
continue;
}
l++;
}
if(ans.size()==(n-k)){
sort(ans.begin(),ans.end());
for(int x:ans)cout<<x<<' ';
return 0;
}
ans.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... |