이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
//Autor: Bartłomiej Czarkowski
#include <bits/stdc++.h>
using namespace std;
#ifdef DEBUG
template<class A,class B>auto&operator<<(ostream&o,pair<A,B>p){return o<<'('<<p.first<<", "<<p.second<<')';}
template<class T>auto operator<<(ostream&o,T x)->decltype(x.end(),o){o<<'{';int i=0;for(auto e:x)o<<(", ")+2*!i++<<e;return o<<'}';}
#define debug(x...) cerr<<"["#x"]: ",[](auto...$){((cerr<<$<<"; "),...);}(x),cerr<<'\n'
#else
#define debug(...) {}
#endif
const int N = 201000;
int n;
int B[N];
int odp[N];
int pref[N];
int suff[N];
pair<int, int> sr[N];
int main() {
scanf("%d", &n);
for (int i = 1; i <= n + 1; ++i) {
scanf("%d", &sr[i].first);
sr[i].second = i;
}
for (int i = 1; i <= n; ++i) {
scanf("%d", &B[i]);
}
sort(sr + 1, sr + 2 + n);
sort(B + 1, B + 1 + n);
for (int i = 1; i <= n; ++i) {
pref[i] = max(pref[i - 1], max(0, sr[i].first - B[i]));
}
for (int i = n + 1; i > 1; --i) {
suff[i] = max(suff[i + 1], max(0, sr[i].first - B[i - 1]));
}
for (int i = 1; i <= n + 1; ++i) {
odp[sr[i].second] = max(pref[i - 1], suff[i + 1]);
}
for (int i = 1; i <= n + 1; ++i) {
printf("%d ", odp[i]);
}
printf("\n");
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
ho_t1.cpp: In function 'int main()':
ho_t1.cpp:21:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
21 | scanf("%d", &n);
| ~~~~~^~~~~~~~~~
ho_t1.cpp:23:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
23 | scanf("%d", &sr[i].first);
| ~~~~~^~~~~~~~~~~~~~~~~~~~
ho_t1.cpp:27:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
27 | 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... |