This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
///
/// Let the voice of love take you higher!
///
#define _USE_MATH_DEFINES
#define FAST ios::sync_with_stdio(false),cin.tie(0);
#include <bits/stdc++.h>
#define Loop(x, l, r) for(ll x = ll(l); x < ll(r); ++x)
#define LoopR(x, l, r) for(ll x = ll(r)-1; x >= ll(l); --x)
#define all(x) x.begin(), x.end()
#define Kill(x) exit((cout << (x) << '\n', 0))
#define YN(flag) ((flag)? "YES": "NO")
#define F first
#define S second
typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int,int> pii;
typedef std::pair<ll ,ll > pll;
using namespace std;
const int N = 100010;
pii a[N];
int b1[N];
int b2[N];
int ans[N];
set<pii, greater<pii>> s;
int n;
int main()
{
FAST;
cin >> n;
Loop(i,0,n+1) cin >> a[i].F, a[i].S=i;
Loop(i,0,n) cin >> b1[i];
sort(b1, b1+n);
sort(a, a+n+1);
Loop(i,0,n) b2[i] = a[i+1].F;
s.insert({0, -1});
Loop(i,0,n) s.emplace(b2[i]-b1[i], i);
Loop(i,0,n+1)
{
ans[a[i].S] = s.begin()->F;
if(i==n) break;
s.erase({b2[i]-b1[i],i});
b2[i] = a[i].F;
s.insert({b2[i]-b1[i],i});
}
Loop(i,0,n+1) cout << ans[i] << ' ';
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |