이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int mx = 2e5+5;
int n;
pair<int,int> a[mx];
int b[mx];
int d[mx], rd[mx];
int ans[mx];
signed main() {
cin.tie(0);ios::sync_with_stdio(0);
cin >> n;
for (int i=0;i<=n;i++) {
cin >> a[i].first;
a[i].second = i;
}
for (int i=0;i<n;i++) {
cin >> b[i];
}
sort(a,a+n+1);
sort(b,b+n);
multiset<int> st;
for (int i=0;i<n;i++) {
st.insert(max(a[i+1].first-b[i],0LL));
// cout << max(a[i+1].first-b[i],0LL) << "\n";
}
ans[a[0].second] = *--st.end();
// cout << a[0].second << " " << st.size() << "\n";
for (int i=0;i<n;i++) {
st.erase(st.find(max(a[i+1].first-b[i], 0LL)));
// cout << max(a[i+1].first-b[i], 0LL) << " " << max(a[i].first-b[i], 0LL) << "\n";
st.insert(max(a[i].first-b[i],0LL));
// cout << a[i].second << "owo\n";
ans[a[i+1].second] = *--st.end();
}
for (int i=0;i<=n;i++) {
cout << ans[i] << " ";
}
cout << "\n";
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |