//khodaya khodet komak kon
#include <bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()
#pragma GCC optimise ("ofast")
#pragma GCC optimise("unroll-loops")
#define int long long
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int N = 200000 + 10;
const ll MOD = 1000000000 + 7;
const ll INF = 1000000000000000000;
const ll LOG = 25;
int n, b[N], pre[N], suf[N], ans[N];
pii a[N];
int32_t main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> n;
for (int i = 1; i <= n + 1; i ++) {cin >> a[i].F; a[i].S = i;}
for (int i = 1; i <= n; i++) cin >> b[i];
sort(a + 1, a + n + 2);
sort(b + 1, b + n + 1);
cout << b[1] << ' ' << a[1].F << '\n';
for (int i = 1; i <= n; i++) pre[i] = max(pre[i - 1], a[i].F - b[i]);
for (int i = n + 1; i > 1; i--) suf[i] = max(suf[i + 1], a[i].F - b[i - 1]);
for (int i = 1; i <= n + 1; i++){
ans[a[i].S] = max(pre[i - 1], suf[i + 1]);
}
for (int i = 1; i <= n + 1; i++) cout << ans[a[i].S] << ' ';
return 0;
}
Compilation message
ho_t1.cpp:8:0: warning: ignoring #pragma GCC optimise [-Wunknown-pragmas]
#pragma GCC optimise ("ofast")
ho_t1.cpp:9:0: warning: ignoring #pragma GCC optimise [-Wunknown-pragmas]
#pragma GCC optimise("unroll-loops")
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
380 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
380 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
380 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |