# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
952161 | SmuggingSpun | Just Long Neckties (JOI20_ho_t1) | C++14 | 170 ms | 18768 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define taskname "justlongneckties"
using namespace std;
const int lim = 2e5 + 5;
const int INF = 1e9;
template<class T>void maximize(T& a, T b){
if(a < b){
a = b;
}
}
int n, a[lim], b[lim], p[lim], ans[lim];
int main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
if(fopen(taskname".inp", "r")){
freopen(taskname".inp", "r", stdin);
}
int n;
cin >> n;
for(int i = 0; i <= n; ){
cin >> a[++i];
}
for(int i = 1; i <= n; i++){
cin >> b[i];
}
sort(b + 1, b + n + 1);
iota(p + 1, p + n + 2, 1);
sort(p + 1, p + n + 2, [&] (int i, int j) -> bool{
return a[i] < a[j];
});
multiset<int>right;
int left = -INF;
for(int i = 1; i <= n; i++){
right.insert(a[p[i + 1]] - b[i]);
}
ans[p[1]] = *right.rbegin();
for(int i = 2; i <= n + 1; i++){
right.erase(right.find(a[p[i]] - b[i - 1]));
maximize(left, a[p[i - 1]] - b[i - 1]);
ans[p[i]] = max(right.empty() ? 0 : *right.rbegin(), left);
}
for(int i = 0; i <= n; ){
cout << max(0, ans[++i]) << " ";
}
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |