# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
445612 | jamezzz | Just Long Neckties (JOI20_ho_t1) | C++17 | 144 ms | 7920 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int n, a, b[200005], c[200005], pmx[200005], smx[200005];
typedef pair<int, int> ii;
vector<ii> v;
int main(){
scanf("%d", &n);
for (int i = 0; i <= n; ++i){
scanf("%d", &a);
v.push_back(ii(a, i));
}
for (int i = 0; i < n; ++i){
scanf("%d", &b[i]);
}
sort(v.begin(), v.end());
sort(b, b + n);
int ans = 0;
for (int i = 1; i <= n; ++i){
ans = max(ans, v[i].first - b[i - 1]);
c[v[0].second] = ans;
}
int sfx = 0;
for (int i = n; i >= 1; --i){
sfx = max(sfx, v[i].first - b[i - 1]);
smx[i] = sfx;
}
smx[n + 1] = 0;
for (int i = 1; i <= n; ++i){
pmx[i] = max(pmx[i - 1], v[i - 1].first - b[i - 1]);
c[v[i].second] = max(pmx[i], smx[i + 1]);
}
for (int i = 0; i <= n; ++i){
printf("%d ", c[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... |