이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define ar array
#define ii pair<int, int>
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define all(a) begin(a), end(a)
const int N = 2e5 + 5;
int n, b[N], it[N << 2], ans[N];
ii a[N];
void upd(int i, int l, int r, int pos, int val) {
if (pos < l || pos > r) return;
if (l == r) {
it[i] = val;
return;
}
int m = (l + r) / 2;
upd(i << 1, l, m, pos, val);
upd(i << 1 | 1, m + 1, r, pos, val);
it[i] = max(it[i << 1], it[i << 1 | 1]);
}
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
#define task "neckti"
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; ++i)
upd(1, 1, n, i, a[i + 1].fi - b[i]);
for (int i = 1; i <= n + 1; ++i) {
ans[a[i].se] = it[1];
upd(1, 1, n, i, a[i].fi - b[i]);
}
for (int i = 1; i <= n + 1; ++i)
cout << ans[i] << ' ';
}
컴파일 시 표준 에러 (stderr) 메시지
ho_t1.cpp: In function 'int32_t main()':
ho_t1.cpp:35:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
35 | freopen(task".inp", "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
ho_t1.cpp:36:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
36 | freopen(task".out", "w", stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |