#include<bits/stdc++.h>
#ifdef _DEBUG
#define ls(x) << (x) << ", "
#define lv(x) << #x << ": " << flush << (x) << ", "
#define pr(x) cout << "Line: " << __LINE__ << ", " x << endl;
#else
#define ls(x)
#define lv(x)
#define pr(x) ;
#endif
using namespace std;
typedef unsigned int uint;
struct Neckle {
uint a;
uint i;
};
bool operator<(Neckle a, Neckle b) {
return a.a < b.a;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
uint n;
cin >> n;
vector<Neckle> a(n+1), b(n);
for (uint i = 0; i < n+1; i++) {
cin >> a[i].a;
a[i].i = i;
}
for (uint i = 0; i < n; i++) {
cin >> b[i].a;
b[i].i = i;
}
sort(a.begin(), a.end());
sort(b.begin(), b.end());
vector<uint> pref(n), suff(n);
pref[0] = 0;
for (uint i = 1; i < n + 1; i++) {
pr(lv(i) lv(a[i].a) lv(b[i].a))
pref[i] = max(pref[i - 1], (uint)abs((int)a[i - 1].a - (int)b[i - 1].a));
}
suff[n] = 0;
// suff[i] = a[i+1].a - b[i].a
for (uint i = n-1; i + 1 > 0; i--) {
pr(lv(i) lv(a[i + 1].a) lv(b[i].a))
suff[i] = max(suff[i+1], (uint)abs((int)a[i+1].a - (int)b[i].a));
}
vector<uint> mapping(n+1);
for (uint i = 0; i < n+1; i++) {
mapping[a[i].i] = i;
pr(lv(i) lv(a[i].a) lv(a[i].i) lv(mapping[a[i].i]))
}
for (uint i = 0; i < n+1; i++) {
uint k = mapping[i];
pr(lv(i) lv(k) lv(suff[k]) lv(pref[k]))
uint result = max(suff[k], pref[k]);
// cout << result << " ";
pr(lv(i) lv(k) lv(result))
}
}
Compilation message
ho_t1.cpp: In function 'int main()':
ho_t1.cpp:61:14: warning: unused variable 'result' [-Wunused-variable]
61 | uint result = max(suff[k], pref[k]);
| ^~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
592 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
592 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
592 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |