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,a,b,c;
vector<int>v,v2;
int main(){
cin>>n>>k;
for(int i=0;i<n+k;i++){
cin>>a;
v.push_back(a);
}
for(int i=0;i<k;i++){
for(int j=0;j+i<n;j++){
v2.clear();
int pocz=i,kon=(int)v.size()-1-j,skipped=i+j,suma=v[i]+v[(int)v.size()-1-j];
v2.push_back(v[i]);
v2.push_back(v[(int)v.size()-1-j]);
pocz++;
kon--;
//cout<<pocz<<kon<<skipped<<" ";
while((int)v2.size()!=n && skipped<k+1){
if(v[pocz]+v[kon]==suma){
v2.push_back(v[pocz]);
v2.push_back(v[kon]);
pocz++;
kon--;
}
else if(v[pocz]+v[kon]<suma){
pocz++;
skipped++;
}
else{
kon--;
skipped++;
}
}
if((int)v2.size()==n){
sort(v2.begin(),v2.end());
for(int l=0;l<(int)v2.size();l++){
cout<<v2[l]<<" ";
}
cout<<"\n";
return 0;
}
}
}
}
# | 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... |