이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
//君の手を握ってしまったら
//孤独を知らないこの街には
//もう二度と帰ってくることはできないのでしょう
//君が手を差し伸べた 光で影が生まれる
//歌って聞かせて この話の続き
//連れて行って見たことない星まで
//さユリ - 花の塔
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define starburst ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pii pair<int,int>
#define pb push_back
#define ff first
#define ss second
#define N 100005
void solve(){
int n; cin >> n;
vector<int> a(n + 1), b(n), ns(n), s(n);
for(auto &x:a) cin >> x;
for(auto &x:b) cin >> x;
sort(a.begin(), a.end());
sort(b.begin(), b.end());
for(int i = 1; i <= n; ++i){
ns[i - 1] = max(0ll, a[i - 1] - b[i - 1]);
s[i - 1] = max(0ll, a[i] - b[i - 1]);
}
for(int i = 1; i < n; ++i){
int j = n - i - 1;
ns[i] = max(ns[i - 1], ns[i]);
s[j] = max(s[j], s[j + 1]);
}
for(int i = 0; i <= n; ++i){
int ans = -1;
if(i != 0){
ans = max(ans, ns[i - 1]);
}
if(i != n) ans = max(ans, s[i]);
cout << max(ans, 0ll) << " \n"[i == n];
}
}
signed main(){
starburst
int t = 1; //cin >> t;
while(t--) solve();
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |