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;
const int NMAX = 1e5 + 5e4 + 5 + 4;
const int KMAX = 404;
int N, K, M, a[NMAX + KMAX], sol[NMAX];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
cin >> N >> K;
M = N + K;
for(int i = 1; i <= M; ++i)
cin >> a[i];
for(int i = 1; i <= K + 1; ++i)
for(int j = i + N - 1; j <= M; ++j) {
/// consideram i primul element al sirului solutie si j ultimul
int sum = a[i] + a[j], st = i, dr = j, cnt = 0;
while(st < dr) {
if((dr - st + 1) < (N - (cnt << 1)))
break;
int cand = a[st] + a[dr];
if(cand == sum) {
sol[++cnt] = a[st];
sol[N - cnt + 1] = a[dr];
++st, --dr;
}
else
if(cand > sum)
--dr;
else
++st;
if(cnt == N / 2)
break;
}
if(cnt == N / 2) {
for(int k = 1; k <= N; ++k)
cout << sol[k] << ' ';
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... |