/*
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣠⡤⢶⡺⠛⢓⡶⢤⣄⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⡟⠀⠀⢀⡗⠀⠸⡇⠀⠈⢻⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣀⣼⠁⠀⢀⡞⠀⣀⠀⢳⡀⠀⠈⣧⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣀⣤⠴⠶⢿⣉⢡⡷⠦⠤⠬⠴⠊⣍⡳⣮⡷⠤⣴⢿⣏⣹⠷⠶⠤⣤⣀⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠠⣶⣶⣛⡉⠁⣀⣀⣀⣀⣈⣿⠲⠦⣤⣀⡴⣊⣭⡑⢬⣻⣷⠷⠖⣿⠤⠤⣤⣤⣀⣀⣉⣉⣻⣿⡿⠃⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠙⠯⣟⡻⠿⣯⣤⣠⠤⠟⠓⢲⡦⣬⣷⣝⣶⣻⣾⣥⣴⣶⡛⠛⠧⢄⣀⣠⡴⠾⠛⣋⡽⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠙⢶⣤⣉⠙⠿⣶⣞⡁⠀⠀⢸⠋⠛⢹⡇⠀⠀⠀⢉⣽⠶⠛⠉⣁⣴⠖⠋⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠛⠷⣦⣈⠙⢿⣦⣀⣸⡇⠀⠈⡇⢀⣤⡾⠛⢁⣠⠖⣫⠟⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣨⡽⠳⢦⡈⠛⢿⣇⣀⣠⡿⠟⢅⣤⠖⠋⣠⡴⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⠻⣇⠀⠸⣿⣷⣄⡉⠛⢋⣠⣾⣿⠗⠀⢠⣿⣧⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣸⠀⠈⠢⡀⠈⠳⠽⠟⠒⠋⠻⠟⠁⠀⢴⠟⣡⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⠀⠀⣀⡈⠓⠦⡄⠀⠀⠀⠀⢀⣠⠞⢁⠔⠹⣿⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣰⠋⠀⣰⣷⣭⣲⡤⠀⠀⠀⠀⠀⠉⠀⠒⠁⠀⠀⢯⠳⣄⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣤⡞⠳⢦⣠⣿⠃⣹⠀⠉⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⡤⠷⠿⠙⢦⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⢀⣠⢶⣫⣿⣿⢿⣦⣀⡿⢿⣰⠏⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣴⡋⠉⢳⡀⢀⢠⣾⣿⣶⣄⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⢀⣠⠖⣫⣵⢿⣽⡿⢿⡽⢻⣏⣀⠴⣻⢳⠦⢤⣤⣤⣤⣤⠴⠖⣛⣧⡙⢟⢦⡀⠙⣟⣿⡺⣾⣝⡿⣯⣗⢤⣀⠀⠀⠀⠀⠀⠀
⠀⠀⣴⣟⣿⣟⣯⣾⢟⣫⣾⡿⠞⠁⢨⠏⡴⣱⠯⠶⠒⠚⣉⣩⠤⠖⠋⠁⠀⠙⣎⢳⡘⣟⠋⠲⣝⣾⣝⣿⣾⣝⠿⣮⣗⣤⣤⡀⠀⠀
⠀⣠⣿⢿⣷⣿⣮⣵⢟⡽⠋⠀⠀⢀⡞⢰⣳⠃⡴⠖⠚⠉⠉⠀⠀⠀⠀⠀⣠⠞⢈⣧⣳⡘⣆⠀⠀⠑⢯⣳⣮⡛⢿⣮⡟⣻⣿⣧⡀⠀
⢘⣿⣷⡞⠻⣿⣟⡵⠋⠀⠀⠀⠀⣼⢀⣧⡏⣸⠃⠀⠀⠀⠀⠀⠀⠀⠀⡴⠁⣠⠞⠈⢧⢧⠸⡄⠀⠀⠀⠉⠫⡻⢿⢟⣾⣿⡙⠻⢷⣄
⠋⠀⠙⠿⣦⣽⣿⣿⡀⠀⠀⠀⢀⡇⢸⣼⢀⡏⠀⠀⠀⠀⠀⠀⠀⢀⡞⠀⡴⠁⠀⠀⠘⡟⡆⢻⠀⠀⠀⠀⠀⢘⣦⣞⡞⢀⣿⣶⣿⣿
⡇⠀⢀⠔⢻⡘⡟⣟⣷⡀⠀⠀⢸⡇⣿⡇⣸⠁⠀⠀⠀⠀⠀⠀⢠⠞⢀⠞⠀⠀⠀⠀⠀⢻⣷⠘⡇⠀⠀⠀⢀⣾⢯⣾⠶⣷⠋⠁⠀⠀
⡟⠛⠁⠀⠘⡇⣧⠘⣿⣷⡄⠀⢸⡇⣿⣇⣿⠀⠀⠀⠀⠀⠀⢀⡎⢠⠏⠀⠀⠀⠀⠀⠀⠸⣿⡄⣇⠀⠀⢀⣾⢏⡞⣼⢸⠇⠉⠲⠤⣀
⡇⠀⠀⠀⠀⣷⢻⠀⠘⢿⣿⠶⠾⢧⡟⢿⡇⠀⠀⠀⠀⠀⠀⡼⢀⡞⠀⠀⠀⠀⠀⠀⠀⠀⣿⡇⣿⠀⢀⣾⢯⡞⠀⡟⣸⠀⠀⠀⠀⠀
⣧⠀⠀⠀⠀⢻⢸⠀⠀⠘⣿⢦⠀⠀⣷⡿⡇⠀⠀⠀⠀⢀⠼⢁⡾⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⡟⠉⠉⢹⣯⠏⠀⠀⡇⣿⠀⠀⠀⠀⠀
⢸⡀⠀⠀⠀⢸⣾⡇⠀⠀⣇⠹⣿⠿⠿⠷⡙⢆⢀⡠⠞⣁⠴⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣷⠤⠴⡿⣿⠀⠀⠀⡇⡿⠀⠀⠀⠀⠀
⠀⢷⡀⠀⣠⢞⡽⠁⠀⢀⡏⣠⠏⠀⠀⠀⠈⢪⡉⣤⠚⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠙⣏⠁⣿⠀⠀⢠⡇⣇⠀⠀⠀⠀⢰
⠀⢺⣍⠉⠹⠊⠀⠀⠀⢸⡛⠁⠀⠀⠀⠀⠀⠘⡇⣷⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⢦⣸⡄⠀⠀⠓⠈⠢⣀⣠⠔⢳
⠀⢠⡏⠀⠀⠀⠀⠀⠀⠈⣳⠀⠀⠀⠀⠀⠀⠀⡇⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⣿⠀⠀⠀⠀⠀⠀⠀⢠⠏
⠀⠀⡇⠀⠀⠀⠀⠀⠀⢸⣟⣇⠀⠀⠀⠀⠀⠀⣷⢸⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣰⣿⠀⠀⠀⠀⠀⠀⠀⢸⠀
*/
// made by djsksbrbf, 2025
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
typedef pair <int, int> pii;
#define pb push_back
#define fi first
#define se second
const int MOD = 1e9 + 7;
const int MAX = 2e5 + 5;
int a[MAX];
int n, k, nk;
vector <int> v;
bool check(int l, int r){
int sum = a[l] + a[r];
v.clear();
v.pb(a[l]);
v.pb(a[r]);
l++;
r--;
int cnt = 1;
while(l <= r && (int)v.size() < n){
if(cnt + (r - l + 1) / 2 < n / 2)return 0;
while(a[l] + a[r] > sum)r--;
if(a[l] + a[r] == sum){
v.pb(a[l]);
v.pb(a[r]);
r--;
cnt++;
}
l++;
}
return (int)v.size() >= n;
}
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n >> k;
/*
_ _ _ _ _ _
x y z y x
*/
nk = n + k;
for(int i = 1 ; i <= nk ; i++)cin >> a[i];
for(int l = 1 ; l <= k + 1 ; l++){
for(int r = nk ; nk -r + l - 1 <= k ; r--){
if(check(l, r)){
sort(v.begin(), v.end());
for(auto it : v)cout<< it << ' ';
cout << endl;
return 0;
}
}
}
cout << "wa" << endl;
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... |