# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1144711 | mingga | Just Long Neckties (JOI20_ho_t1) | C++20 | 64 ms | 11592 KiB |
#include "bits/stdc++.h"
using namespace std;
#define ln "\n"
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define int long long
const int mod = 1e9 + 7;
const int inf = 2e18;
const int N = 2e5 + 7;
int n;
pair<int, int> a[N];
int b[N], ans[N], mx_lef[N], mx_rig[N];
signed main() {
cin.tie(0) -> sync_with_stdio(0);
#define task ""
if(fopen(task ".INP", "r")) {
freopen(task ".INP", "r", stdin);
freopen(task ".OUT", "w", stdout);
}
cin >> n;
for(int i = 1; i <= n + 1; i++) cin >> a[i].fi, a[i].se = i;
for(int i = 1; i <= n; i++) cin >> b[i];
sort(a + 1, a + n + 2);
sort(b + 1, b + n + 1);
for(int i = 1; i <= n + 1; i++) {
mx_lef[i] = max(mx_lef[i - 1], (a[i].fi - b[i]));
}
for(int i = n; i > 0; i--) {
mx_rig[i] = max(mx_rig[i + 1], a[i + 1].fi - b[i]);
}
for(int i = 1; i <= n + 1; i++) {
ans[a[i].se] = max(mx_lef[i - 1], mx_rig[i]);
}
for(int i = 1; i <= n + 1; i++) cout << ans[i] << ' ';
cerr << "\nTime: " << clock() * 1000 / CLOCKS_PER_SEC;
}
컴파일 시 표준 에러 (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... |