//we are all lost trying to be someone.
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(0); cin.tie(0);
#define sz(x) ll(x.size())
#define reve(x) reverse(x.begin(),x.end())
#define ff first
#define ss second
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> ii;
const ll MAX=3*(1e6+100);
const ll mod=1e9+7;
const ll inf=1e18+7;
ll A[MAX], s[1610];
vector<ll >c;
bool nice=false;
ll n, k;
void solve(ll sum){
ll j=n+k-1;
for(ll i=0; i<(n+k)/2; i++){
while(j-1>=0 and A[j-1]>=sum-A[i]){
j--;
}
if( j>=0 and A[j]==sum-A[i]){
c.push_back(A[j]);
c.push_back(A[i]);
if(sz(c)>=n){
nice=true;
return;
}
}
}
return;
}
int main(){
cin>>n>>k;
for(ll i=0; i<n+k; i++){
cin>>A[i];
}
sort(A,A+n+k);
ll cont=0;
for(ll i=0; i<k+1; i++){
for(ll j=n+k-1; j>=n-1; j--){
s[cont]=A[i]+A[j];
cont++;
}
}
for(ll i=0; i<cont; i++){
solve(s[i]);
if(nice)break;
c.clear();
}
sort(c.begin(),c.end());
for(ll i=0; i<sz(c); i++){
cout<<c[i]<<" ";
}
cout<<'\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
340 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
852 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
57 ms |
4196 KB |
Output is correct |
2 |
Correct |
59 ms |
4208 KB |
Output is correct |
3 |
Incorrect |
44 ms |
3648 KB |
Unexpected end of file - int32 expected |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
340 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
2 ms |
340 KB |
Unexpected end of file - int32 expected |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
276 ms |
3632 KB |
Unexpected end of file - int32 expected |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
83 ms |
1540 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |