#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <tuple>
#include <math.h>
#include <set>
#include <stack>
#include <bitset>
#include <map>
#include <queue>
#include <random>
#include <array>
#include <unordered_set>
#include <cmath>
#include <cassert>
#include <unordered_map>
#define DEBUG
#define pqueue priority_queue
#define pb(x) push_back(x)
//#define endl '\n'
#define all(x) x.begin(), x.end()
#define int long long
#define mk(a, b) make_pair(a, b)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ull> vull;
typedef vector<ll> vll;
// typedef tuple<ll, ll, ll> tiii;
typedef pair<int, int> pii;
typedef vector<pair<int, int> > vpii;
typedef pair<ll, ll> pll;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<vector<int> > vvi;
typedef vector<char> vc;
const ll inf = 3e9 + 228;
const ll infll = 1e18 + 228;
const ll mod = 1e9 + 7;
const ll mod3 = 1e9 + 7;
//static const int maxn = 1e6 + 228;
const ld eps = 1e-6;
const ll mod2 = 998244353;
const ld PI = atan2l(0, -1);
void fast_io() {
// ios_base::sync_with_stdio(0);
// cin.tie(0);
// cout.tie(0);
// freopen("main.in", "r", stdin);
// freopen("lumber.out", "w", stdout);
}
void solve() {
int n;
cin >> n;
vpii a(n + 1);
vi b(n);
for(int i=0; i<n+1; i++){
cin >> a[i].first;
a[i].second = i;
}
for(int &i:b)
cin >> i;
sort(all(a));
sort(all(b));
multiset<int> kek;
for(int i=0; i<n; i++){
kek.insert(b[i] - a[i + 1].first);
}
vi ans(n + 1);
ans[a[0].second] = *(kek.begin());
for(int i=0; i<n; i++){
kek.erase(kek.find(b[i] - a[i + 1].first));
kek.insert(b[i] - a[i].first);
ans[a[i + 1].second] = *(kek.begin());
}
for(int i:ans)
cout << max(-i, 0ll) << " ";
cout << endl;
}
/*
3
4 3 7 6
2 6 4
*/
signed main() {
srand(time(NULL));
fast_io();
int q = 1;
// cin >> q;
while (q--)
solve();
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
300 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
300 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
300 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
300 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
2 ms |
436 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
2 ms |
440 KB |
Output is correct |
18 |
Correct |
2 ms |
340 KB |
Output is correct |
19 |
Correct |
2 ms |
440 KB |
Output is correct |
20 |
Correct |
3 ms |
452 KB |
Output is correct |
21 |
Correct |
3 ms |
468 KB |
Output is correct |
22 |
Correct |
3 ms |
340 KB |
Output is correct |
23 |
Correct |
2 ms |
388 KB |
Output is correct |
24 |
Correct |
2 ms |
468 KB |
Output is correct |
25 |
Correct |
3 ms |
384 KB |
Output is correct |
26 |
Correct |
3 ms |
468 KB |
Output is correct |
27 |
Correct |
3 ms |
468 KB |
Output is correct |
28 |
Correct |
3 ms |
468 KB |
Output is correct |
29 |
Correct |
2 ms |
340 KB |
Output is correct |
30 |
Correct |
3 ms |
468 KB |
Output is correct |
31 |
Correct |
3 ms |
444 KB |
Output is correct |
32 |
Correct |
2 ms |
468 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
300 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
300 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
2 ms |
436 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
2 ms |
440 KB |
Output is correct |
18 |
Correct |
2 ms |
340 KB |
Output is correct |
19 |
Correct |
2 ms |
440 KB |
Output is correct |
20 |
Correct |
3 ms |
452 KB |
Output is correct |
21 |
Correct |
3 ms |
468 KB |
Output is correct |
22 |
Correct |
3 ms |
340 KB |
Output is correct |
23 |
Correct |
2 ms |
388 KB |
Output is correct |
24 |
Correct |
2 ms |
468 KB |
Output is correct |
25 |
Correct |
3 ms |
384 KB |
Output is correct |
26 |
Correct |
3 ms |
468 KB |
Output is correct |
27 |
Correct |
3 ms |
468 KB |
Output is correct |
28 |
Correct |
3 ms |
468 KB |
Output is correct |
29 |
Correct |
2 ms |
340 KB |
Output is correct |
30 |
Correct |
3 ms |
468 KB |
Output is correct |
31 |
Correct |
3 ms |
444 KB |
Output is correct |
32 |
Correct |
2 ms |
468 KB |
Output is correct |
33 |
Correct |
277 ms |
20284 KB |
Output is correct |
34 |
Correct |
292 ms |
21192 KB |
Output is correct |
35 |
Correct |
273 ms |
20492 KB |
Output is correct |
36 |
Correct |
282 ms |
21160 KB |
Output is correct |
37 |
Correct |
294 ms |
21732 KB |
Output is correct |
38 |
Correct |
284 ms |
21456 KB |
Output is correct |
39 |
Correct |
346 ms |
20424 KB |
Output is correct |
40 |
Correct |
398 ms |
20288 KB |
Output is correct |
41 |
Correct |
335 ms |
20556 KB |
Output is correct |
42 |
Correct |
336 ms |
20472 KB |
Output is correct |
43 |
Correct |
353 ms |
20404 KB |
Output is correct |
44 |
Correct |
290 ms |
19848 KB |
Output is correct |
45 |
Correct |
280 ms |
19904 KB |
Output is correct |
46 |
Correct |
283 ms |
19660 KB |
Output is correct |
47 |
Correct |
265 ms |
20348 KB |
Output is correct |
48 |
Correct |
270 ms |
20332 KB |
Output is correct |
49 |
Correct |
343 ms |
20948 KB |
Output is correct |
50 |
Correct |
366 ms |
20960 KB |
Output is correct |
51 |
Correct |
366 ms |
20964 KB |
Output is correct |
52 |
Correct |
351 ms |
21004 KB |
Output is correct |
53 |
Correct |
363 ms |
20884 KB |
Output is correct |