#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = std::vector<int>;
using pi = std::pair<int, int>;
#define REP(i,a,b) for(int i{ a }; i < b; ++i)
#define MP std::make_pair
#define PB push_back
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
void solve(int no) {
int n{};
cin >> n;
vector<pi> a(n + 1); // avail ties
REP(i, 0, n + 1) {
a[i] = { 0, i };
cin >> a[i].first;
}
vi b(n); // curr ties
REP(i, 0, n) {
cin >> b[i];
}
sort(ALL(a));
sort(ALL(b));
multiset<int> strange{};
REP(i, 0, n) {
strange.insert(max(0, a[i + 1].first - b[i]));
}
vi res(n);
for(int i{ 0 }; i <= n; ++i) {
auto ans{ --strange.end() };
res[a[i].second] = *ans;
if(i == n) break;
strange.erase(lower_bound(ALL(strange), a[i + 1].first - b[i]));
strange.insert(a[i].first - b[i]);
}
for(int a : res) cout << a << ' ';
cout << '\n';
}
int main() {
std::ios_base::sync_with_stdio(false);
std::cin.tie(0);
solve(0);
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |