#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
ll n; cin >> n;
vector<pair<ll,int>> v(n+1), x(n);
int cn = 0;
for(auto &i : v){cin >> i.first;i.second = cn;cn++;}
cn = 0;
for(auto &i : x){cin >> i.first;i.second = cn;cn++;}
sort(v.begin(), v.end());
sort(x.begin(), x.end());
vector<int> out(n+1);
map<ll,int> M;
for(int i = 1; i <= n; ++i){
M[max(0LL,v[i].first-x[i-1].first)]++;
}
out[v[0].second] = M.rbegin()->first;
for(int i = 1; i <= n; ++i){
M[max(0LL,v[i].first-x[i-1].first)]--;
M[max(0LL,v[i-1].first-x[i-1].first)]++;
if(!M[max(0LL,v[i].first-x[i-1].first)])M.erase(max(0LL,v[i].first-x[i-1].first));
out[v[i].second] = M.rbegin()->first;
}
for(auto i : out)cout << i << " ";
cout << "\n";
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
1 ms |
256 KB |
Output is correct |
3 |
Correct |
1 ms |
256 KB |
Output is correct |
4 |
Correct |
0 ms |
256 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
256 KB |
Output is correct |
7 |
Correct |
1 ms |
256 KB |
Output is correct |
8 |
Correct |
0 ms |
256 KB |
Output is correct |
9 |
Correct |
1 ms |
256 KB |
Output is correct |
10 |
Correct |
0 ms |
256 KB |
Output is correct |
11 |
Correct |
1 ms |
384 KB |
Output is correct |
12 |
Correct |
1 ms |
256 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
1 ms |
256 KB |
Output is correct |
3 |
Correct |
1 ms |
256 KB |
Output is correct |
4 |
Correct |
0 ms |
256 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
256 KB |
Output is correct |
7 |
Correct |
1 ms |
256 KB |
Output is correct |
8 |
Correct |
0 ms |
256 KB |
Output is correct |
9 |
Correct |
1 ms |
256 KB |
Output is correct |
10 |
Correct |
0 ms |
256 KB |
Output is correct |
11 |
Correct |
1 ms |
384 KB |
Output is correct |
12 |
Correct |
1 ms |
256 KB |
Output is correct |
13 |
Correct |
1 ms |
256 KB |
Output is correct |
14 |
Correct |
3 ms |
384 KB |
Output is correct |
15 |
Correct |
4 ms |
512 KB |
Output is correct |
16 |
Correct |
1 ms |
384 KB |
Output is correct |
17 |
Correct |
5 ms |
512 KB |
Output is correct |
18 |
Correct |
5 ms |
512 KB |
Output is correct |
19 |
Correct |
5 ms |
512 KB |
Output is correct |
20 |
Correct |
5 ms |
512 KB |
Output is correct |
21 |
Correct |
5 ms |
512 KB |
Output is correct |
22 |
Correct |
5 ms |
556 KB |
Output is correct |
23 |
Correct |
4 ms |
512 KB |
Output is correct |
24 |
Correct |
4 ms |
512 KB |
Output is correct |
25 |
Correct |
5 ms |
640 KB |
Output is correct |
26 |
Correct |
5 ms |
512 KB |
Output is correct |
27 |
Correct |
5 ms |
512 KB |
Output is correct |
28 |
Correct |
4 ms |
512 KB |
Output is correct |
29 |
Correct |
4 ms |
512 KB |
Output is correct |
30 |
Correct |
4 ms |
512 KB |
Output is correct |
31 |
Correct |
4 ms |
512 KB |
Output is correct |
32 |
Correct |
4 ms |
512 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
1 ms |
256 KB |
Output is correct |
3 |
Correct |
1 ms |
256 KB |
Output is correct |
4 |
Correct |
0 ms |
256 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
256 KB |
Output is correct |
7 |
Correct |
1 ms |
256 KB |
Output is correct |
8 |
Correct |
0 ms |
256 KB |
Output is correct |
9 |
Correct |
1 ms |
256 KB |
Output is correct |
10 |
Correct |
0 ms |
256 KB |
Output is correct |
11 |
Correct |
1 ms |
384 KB |
Output is correct |
12 |
Correct |
1 ms |
256 KB |
Output is correct |
13 |
Correct |
1 ms |
256 KB |
Output is correct |
14 |
Correct |
3 ms |
384 KB |
Output is correct |
15 |
Correct |
4 ms |
512 KB |
Output is correct |
16 |
Correct |
1 ms |
384 KB |
Output is correct |
17 |
Correct |
5 ms |
512 KB |
Output is correct |
18 |
Correct |
5 ms |
512 KB |
Output is correct |
19 |
Correct |
5 ms |
512 KB |
Output is correct |
20 |
Correct |
5 ms |
512 KB |
Output is correct |
21 |
Correct |
5 ms |
512 KB |
Output is correct |
22 |
Correct |
5 ms |
556 KB |
Output is correct |
23 |
Correct |
4 ms |
512 KB |
Output is correct |
24 |
Correct |
4 ms |
512 KB |
Output is correct |
25 |
Correct |
5 ms |
640 KB |
Output is correct |
26 |
Correct |
5 ms |
512 KB |
Output is correct |
27 |
Correct |
5 ms |
512 KB |
Output is correct |
28 |
Correct |
4 ms |
512 KB |
Output is correct |
29 |
Correct |
4 ms |
512 KB |
Output is correct |
30 |
Correct |
4 ms |
512 KB |
Output is correct |
31 |
Correct |
4 ms |
512 KB |
Output is correct |
32 |
Correct |
4 ms |
512 KB |
Output is correct |
33 |
Correct |
521 ms |
20176 KB |
Output is correct |
34 |
Correct |
591 ms |
23744 KB |
Output is correct |
35 |
Correct |
487 ms |
18552 KB |
Output is correct |
36 |
Correct |
591 ms |
24184 KB |
Output is correct |
37 |
Correct |
609 ms |
25080 KB |
Output is correct |
38 |
Correct |
583 ms |
24972 KB |
Output is correct |
39 |
Correct |
475 ms |
13432 KB |
Output is correct |
40 |
Correct |
472 ms |
13688 KB |
Output is correct |
41 |
Correct |
480 ms |
13560 KB |
Output is correct |
42 |
Correct |
476 ms |
13432 KB |
Output is correct |
43 |
Correct |
473 ms |
13432 KB |
Output is correct |
44 |
Correct |
405 ms |
12024 KB |
Output is correct |
45 |
Correct |
411 ms |
12020 KB |
Output is correct |
46 |
Correct |
404 ms |
12024 KB |
Output is correct |
47 |
Correct |
445 ms |
14456 KB |
Output is correct |
48 |
Correct |
446 ms |
14328 KB |
Output is correct |
49 |
Correct |
486 ms |
13816 KB |
Output is correct |
50 |
Correct |
487 ms |
13816 KB |
Output is correct |
51 |
Correct |
487 ms |
13832 KB |
Output is correct |
52 |
Correct |
496 ms |
13688 KB |
Output is correct |
53 |
Correct |
482 ms |
13816 KB |
Output is correct |