#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize ("Ofast")
#pragma GCC target("fma,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("unroll-loops")
int main () {
ios::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
vector<pair<int, int> > a (n + 1);
for (int i = 0; i <= n; i++) {
cin >> a[i].first;
a[i].second = i;
}
vector<int> pessoas (n);
for (int i = 0; i < n; i++) cin >> pessoas[i];
sort (a.begin(), a.end());
sort (pessoas.begin(), pessoas.end());
multiset<int> diff;
for (int i = 0; i < n; i++) {
diff.insert( max (a[i].first - pessoas[i], 0) );
}
vector<int> ans (n + 1, -1);
ans.back () = *diff.rbegin();
int last = a[n].first;
for (int i = n - 1; i >= 0; i--) {
int current = a[i].first - pessoas[i];
diff.erase(diff.lower_bound(current));
diff.insert(last - pessoas[i]);
ans[i] = *diff.rbegin();
last = a[i].first;
}
for (int i = 0; i <= n; i++) {
if (i) cout << ' ';
cout << ans[i];
}
cout << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |