# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
244847 | maximath_1 | Just Long Neckties (JOI20_ho_t1) | C++11 | 185 ms | 7032 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int n = 0;
vector<int> a, b, id, pos, pref, suff;
bool cmp(int x, int y){
return a[x] < a[y];
}
int main(){
scanf("%d", &n);
a.resize(n + 1); id.resize(n + 1); pos.resize(n + 1);
b.resize(n);
for(int i = 0; i <= n; i ++){
scanf("%d", &a[i]);
id[i] = i;
}
for(int i = 0; i < n; i ++)
scanf("%d", &b[i]);
sort(id.begin(), id.end(), cmp); sort(a.begin(), a.end());
for(int i = 0; i <= n; i ++)
pos[id[i]] = i;
sort(b.begin(), b.end());
pref.assign(n + 1, 0); suff.assign(n + 1, 0);
for(int i = 1; i <= n; i ++)
pref[i] = max(pref[i - 1], a[i - 1] - b[i - 1]);
for(int i = n - 1; i >= 0; i --)
suff[i] = max(suff[i + 1], a[i + 1] - b[i]);
for(int i = 0; i <= n; i ++)
printf("%d%c", max(pref[pos[i]], suff[pos[i]]), i == n ? '\n' : ' ');
return 0;
}
컴파일 시 표준 에러 (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... |