#include <bits/stdc++.h>
#include <ext/rope>
using namespace std;
using namespace __gnu_cxx;
#pragma GCC optimize("-Ofast")
#pragma GCC optimize("-O1")
//-------------------------------------------------------------//
typedef long long ll;
typedef unsigned long long ull;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define PI acos(-1)
#define lb lower_bound
#define ub upper_bound
#define endl '\n'
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define sum_to(n) (n*(n+1))/2
#define pb push_back
#define pf push_front
#define sz size()
#define fil(arr,x) memset(arr,x,sizeof(arr))
const ll mod=1e9+7;
int dx[8]={0,1,0,-1,1,1,-1,-1};
int dy[8]={1,0,-1,0,1,-1,-1,1};
//-------------------------------------------------------------//
ll lcm(ll a,ll b)
{
return (max(a,b)/__gcd(a,b))*min(a,b);
}
void person_bool(bool x)
{
cout<<(x?"YES":"NO")<<endl;
}
int main()
{
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
fast
int n,k;cin>>n>>k;
vector<int>arr(n+k);
for(auto &i:arr){
cin>>i;
}
for(int i=0;i<=k;i++){
for(int j=n-1;j<n+k;j++){
int s=arr[i]+arr[j];
vector<int>v;
int l=0,r=n+k-1;
int cnt=n;
while(l<r){
if(!cnt)break;
if(arr[l]+arr[r]<s){
++l;
}
else if(arr[l]+arr[r]>s){
--r;
}
else{
v.pb(arr[l]);
v.pb(arr[r]);
++l;--r;
cnt-=2;
}
}
if(!cnt){
sort(all(v));
for(int g=0;g<n;g++){
cout<<v[g]<<" ";
}
return 0;
}
}
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
704 KB |
Output is correct |
2 |
Correct |
34 ms |
3008 KB |
Output is correct |
3 |
Correct |
32 ms |
3016 KB |
Output is correct |
4 |
Correct |
33 ms |
4472 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
34 ms |
3024 KB |
Output is correct |
2 |
Correct |
33 ms |
3016 KB |
Output is correct |
3 |
Correct |
36 ms |
4504 KB |
Output is correct |
4 |
Correct |
35 ms |
4496 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
4 ms |
316 KB |
Output is correct |
3 |
Correct |
0 ms |
320 KB |
Output is correct |
4 |
Correct |
2 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
316 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
324 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
2 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
328 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
238 ms |
4536 KB |
Output is correct |
3 |
Correct |
36 ms |
4428 KB |
Output is correct |
4 |
Correct |
60 ms |
4540 KB |
Output is correct |
5 |
Correct |
38 ms |
4548 KB |
Output is correct |
6 |
Correct |
50 ms |
5508 KB |
Output is correct |
7 |
Correct |
62 ms |
4516 KB |
Output is correct |
8 |
Correct |
40 ms |
4560 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Execution timed out |
3024 ms |
2292 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |