이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool mnto(T& a, T b) {return a > b ? a = b, 1 : 0;}
template <class T>
inline bool mxto(T& a, T b) {return a < b ? a = b, 1: 0;}
#define REP(i, s, e) for (int i = s; i < e; i++)
#define RREP(i, s, e) for (int i = s; i >= e; i--)
typedef long long ll;
typedef long double ld;
#define MP make_pair
#define FI first
#define SE second
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
#define MT make_tuple
typedef tuple<int, int, int> iii;
#define ALL(_a) _a.begin(), _a.end()
#define pb push_back
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ii> vii;
#ifdef DEBUG
#define debug(args...) _debug(args)
void _debug(const char* format, ...) {
va_list args;
va_start(args, format);
vprintf(format, args);
va_end(args);
}
#else
#define debug(args...)
#endif
#define INF 1000000005
#define LINF 1000000000000000005
#define MOD 1000000007
#define MAXN 200005
int n;
ii a[MAXN];
int b[MAXN];
ll pre[MAXN], pst[MAXN], ans[MAXN];
int main() {
scanf("%d", &n);
REP (i, 1, n + 2) {
scanf("%d", &a[i].FI);
a[i].SE = i;
}
REP (i, 1, n + 1) {
scanf("%d", &b[i]);
}
sort(a + 1, a + n + 2);
sort(b + 1, b + n + 1);
REP (i, 1, n + 1) {
pre[i] = abs(a[i].FI - b[i]);
debug("%d: %d\n", i, pre[i]);
mxto(pre[i], pre[i - 1]);
}
RREP (i, n + 1, 2) {
pst[i] = abs(a[i].FI - b[i - 1]);
debug("%d: %d\n", i, pst[i]);
mxto(pst[i], pst[i + 1]);
}
REP (i, 1, n + 2) {
debug("%d: %d %d\n", a[i].SE, pre[i - 1], pst[i + 1]);
ans[a[i].SE] = max(pre[i - 1], pst[i + 1]);
}
REP (i, 1, n + 2) {
printf("%lld ", ans[i]);
}
printf("\n");
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
ho_t1.cpp: In function 'int main()':
ho_t1.cpp:48:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
48 | scanf("%d", &n);
| ~~~~~^~~~~~~~~~
ho_t1.cpp:50:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
50 | scanf("%d", &a[i].FI);
| ~~~~~^~~~~~~~~~~~~~~~
ho_t1.cpp:54:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
54 | 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... |