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 <algorithm>
#include <iostream>
#include <vector>
#define endl '\n'
using namespace std;
const int MAXN = 150000;
const int MAXK = 400;
int a[MAXN + MAXK + 5];
int main()
{
ios :: sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
int N, K;
cin >> N >> K;
for (int i = 1; i <= N + K; ++ i)
{
cin >> a[i];
}
for (int i = 1; i <= K + 1; ++ i)
{
for (int j = N; j <= N + K; ++ j)
{
int i0 = i, j0 = j, cnt = 0;
vector<int> v1, v2;
while (i0 < j0 and (j0 - i0 + 1) / 2 + cnt >= N / 2 and cnt < N / 2)
{
if (a[i0] + a[j0] == a[i] + a[j])
{
v1.push_back(i0);
v2.push_back(j0);
i0++;
j0--;
cnt++;
}
else if (a[i0] + a[j0] < a[i] + a[j]) i0++;
else j0--;
}
if (cnt == N / 2)
{
reverse(v2.begin(), v2.end());
for (auto it : v1)
{
cout << a[it] << " ";
}
for (auto it : v2)
{
cout << a[it] << " ";
}
cout << 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... |