#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+1;i++){
for(int j=0;j+i<k+1;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]<<" ";
}
return 0;
}
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
1116 KB |
Output is correct |
2 |
Correct |
56 ms |
4684 KB |
Output is correct |
3 |
Correct |
64 ms |
4512 KB |
Output is correct |
4 |
Correct |
65 ms |
4424 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
56 ms |
4420 KB |
Output is correct |
2 |
Correct |
57 ms |
4564 KB |
Output is correct |
3 |
Correct |
57 ms |
4500 KB |
Output is correct |
4 |
Correct |
56 ms |
4424 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
436 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
2 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
2 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
57 ms |
4652 KB |
Output is correct |
3 |
Correct |
60 ms |
4536 KB |
Output is correct |
4 |
Correct |
56 ms |
4428 KB |
Output is correct |
5 |
Correct |
56 ms |
4508 KB |
Output is correct |
6 |
Correct |
57 ms |
4684 KB |
Output is correct |
7 |
Correct |
62 ms |
4480 KB |
Output is correct |
8 |
Correct |
56 ms |
4424 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
73 ms |
4460 KB |
Output is correct |
3 |
Correct |
57 ms |
4608 KB |
Output is correct |
4 |
Correct |
71 ms |
4424 KB |
Output is correct |
5 |
Correct |
56 ms |
4424 KB |
Output is correct |
6 |
Correct |
57 ms |
4684 KB |
Output is correct |
7 |
Correct |
92 ms |
4432 KB |
Output is correct |
8 |
Correct |
60 ms |
4420 KB |
Output is correct |