이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
int ppl[maxn], ans[maxn];
multiset<int> st;
pair<int, int> ties[maxn];
int main(){
int n; cin >> n;
for(int i = 0; i <= n; i++) cin >> ties[i].first;
for(int i = 0; i < n; i++) cin >> ppl[i];
for(int i = 0; i <= n; i++) ties[i].second = i;
sort(ppl, ppl+n);
sort(ties, ties+n+1);
for(int i = 1; i <= n; i++) st.insert(ties[i].first-ppl[i-1]);
// ans[tie[0].second] = st.rbegin();
ans[ties[0].second] = max(0, *st.rbegin());
for(int i = 0; i < n; i++){
int id = ties[i+1].second;
// cout << i << " " << id << "\n";
st.insert(ties[i].first-ppl[i]);
st.erase(st.find(ties[i+1].first-ppl[i]));
ans[id] = max(0, *st.rbegin());
}
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... |