# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
691386 | Aiperiii | Table Tennis (info1cup20_tabletennis) | C++14 | 71 ms | 5724 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;
int n,k;
long long a[150401];
void check(int begin,int end){
vector <long long> ans;
int l=begin+1;
int r=end-1;
int bad=begin+n+k+1-end;
long long t=a[r]+a[l];
while(l<r){
long long c=a[r]+a[l];
if(c==t){
ans.push_back(a[r]);
ans.push_back(a[l]);
l++;
r--;
if(ans.size()==n){
sort(ans.begin(),ans.end());
for(int i=0;i<ans.size();i++){
cout<<ans[i]<<" ";
}
exit(0);
}
}
else if(c<t){
l++;
bad++;
}
else{
r--;
bad++;
}
if(bad>k){
return;
}
}
}
int main(){
cin.tie(0);
ios_base::sync_with_stdio(0);
cin>>n>>k;
for(int i=1;i<=n+k;i++){
cin>>a[i];
}
for(int i=0;i<=k;i++){
for(int j=0;j<=k-i;j++){
check(i,n+k+1-j);
}
}
}
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... |