이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define LL long long
#define pb push_back
#define mp make_pair
#define ss(x) (int) x.size()
#define fi first
#define se second
#define cat(x) cerr << #x << " = " << x << endl
#define rep(i, j, n) for (int i = j; i <= n; ++i)
#define per(i, j, n) for (int i = n; j <= i; --i)
using namespace std;
const int nax = 2e5 + 111;
int n;
pair<int,int> a[nax];
int b[nax];
int s[nax][2];
int ans[nax];
int main() {
scanf ("%d", &n);
rep(i, 1, n + 1) {
scanf ("%d", &a[i].fi);
a[i].se = i;
}
rep(i, 1, n) scanf ("%d", b + i);
sort(b + 1, b + n + 1);
sort(a + 1, a + n + 2);
rep(i, 1, n) {
s[i][0] = max(0, a[i].fi - b[i]);
s[i][1] = max(0, a[i + 1].fi - b[i]);
}
rep(i, 1, n) s[i][0] = max(s[i][0], s[i - 1][0]);
per(i, 1, n) s[i][1] = max(s[i][1], s[i + 1][1]);
rep(i, 1, n + 1) {
// printf ("%d %d %d\n", i, s[i - 1][0], s[i][1]);
int x = (i > 0 ? s[i - 1][0] : 0);
x = max(x, s[i][1]);
ans[a[i].se] = x;
}
rep(i, 1, n + 1) printf ("%d ", ans[i]);
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
ho_t1.cpp: In function 'int main()':
ho_t1.cpp:23:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf ("%d", &n);
~~~~~~^~~~~~~~~~
ho_t1.cpp:25:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf ("%d", &a[i].fi);
~~~~~~^~~~~~~~~~~~~~~~
ho_t1.cpp:28:21: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
rep(i, 1, n) scanf ("%d", b + i);
~~~~~~^~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |