이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
ll n; cin >> n;
vector<pair<ll,int>> v(n+1), x(n);
int cn = 0;
for(auto &i : v){cin >> i.first;i.second = cn;cn++;}
cn = 0;
for(auto &i : x){cin >> i.first;i.second = cn;cn++;}
sort(v.begin(), v.end());
sort(x.begin(), x.end());
vector<int> out(n+1);
map<ll,int> M;
for(int i = 1; i <= n; ++i){
M[max(0LL,v[i].first-x[i-1].first)]++;
}
out[v[0].second] = M.rbegin()->first;
for(int i = 1; i <= n; ++i){
M[max(0LL,v[i].first-x[i-1].first)]--;
M[max(0LL,v[i-1].first-x[i-1].first)]++;
if(!M[max(0LL,v[i].first-x[i-1].first)])M.erase(max(0LL,v[i].first-x[i-1].first));
out[v[i].second] = M.rbegin()->first;
}
for(auto i : out)cout << 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... |