이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <chrono>
#include <vector>
#include <algorithm>
#define maxn 200005
#define maxlog 20
#define INF 1000000010
#define LINF 1000000000000000005
#define endl '\n'
#define pb(x) push_back(x)
#define X first
#define Y second
#define control cout<<"passed"<<endl;
#pragma GCC optimize("O3" , "Ofast" , "unroll-loops" , "fast-math")
#pragma GCC target("avx2")
using namespace std;
std::chrono::high_resolution_clock::time_point startT, currT;
constexpr double TIME_MULT = 1;
double timePassed()
{
using namespace std::chrono;
currT = high_resolution_clock::now();
double time = duration_cast<duration<double>>(currT - startT).count();
return time * TIME_MULT;
}
int n , k;
int a[maxn];
void read()
{
cin >> n >> k;
for(int i = 0; i < n + k; i++)
cin >> a[i];
}
void solve()
{
vector <int> ans;
ans.resize(n);
int start = (n / 2) - 1;
for(int i = start; i <= start + k; i++)
{
int pom = a[i] + a[i + 1];
int l = 0 , r = n + k - 1;
int j = 0;
while(r > l && j < n / 2)
{
while(r > l && (a[l] + a[r]) > pom)
r--;
if(r > l && (a[l] + a[r]) == pom)
{
ans[j] = a[l];
ans[n - j - 1] = a[r];
j++;
}
l++;
}
if(n / 2 > j)
continue;
for(int e : ans)
cout << e << " ";
cout << endl;
break;
}
}
int main()
{
/**#ifdef ONLINE_JUDGE
freopen("taxi.in", "r", stdin);
freopen("taxi.out", "w", stdout);
#endif*/
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
startT = std::chrono::high_resolution_clock::now();
read();
solve();
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... |