#include <bits/stdc++.h>
#define PB push_back
#define ST first
#define ND second
#define _ ios_base::sync_with_stdio(0); cin.tie(0);
//mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
using namespace std;
using ll = long long;
using pi = pair<int,int>;
using vi = vector<int>;
const int nax = 200*1000+10;
int n;
pi a[nax];
int b[nax];
int ans[nax];
priority_queue<pi>PQ;
int main() {_
cin>>n;
for(int i=1; i<=n+1; i++) {
cin>>a[i].ST;
a[i].ND = i;
}
for(int i=1; i<=n; i++) cin>>b[i];
sort(a+1,a+n+2);
sort(b+1,b+n+1);
for(int i=2; i<=n+1; i++) {
PQ.push({a[i].ST-b[i-1],i});
}
for(int i=1; i<=n+1; i++) {
ans[a[i].ND] = max(0,PQ.top().ST);
PQ.push({a[i].ST-b[i],i+n+1});
while(!PQ.empty()&&PQ.top().ND<=i+1) {
PQ.pop();
}
}
for(int i=1; i<=n+1; i++) {
cout<<ans[i]<<" ";
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
6 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
4 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
4 ms |
384 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Correct |
4 ms |
384 KB |
Output is correct |
10 |
Correct |
5 ms |
384 KB |
Output is correct |
11 |
Correct |
5 ms |
384 KB |
Output is correct |
12 |
Correct |
4 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
6 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
4 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
4 ms |
384 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Correct |
4 ms |
384 KB |
Output is correct |
10 |
Correct |
5 ms |
384 KB |
Output is correct |
11 |
Correct |
5 ms |
384 KB |
Output is correct |
12 |
Correct |
4 ms |
384 KB |
Output is correct |
13 |
Correct |
4 ms |
384 KB |
Output is correct |
14 |
Correct |
5 ms |
512 KB |
Output is correct |
15 |
Correct |
7 ms |
512 KB |
Output is correct |
16 |
Correct |
5 ms |
384 KB |
Output is correct |
17 |
Correct |
6 ms |
512 KB |
Output is correct |
18 |
Correct |
5 ms |
512 KB |
Output is correct |
19 |
Correct |
5 ms |
448 KB |
Output is correct |
20 |
Correct |
6 ms |
512 KB |
Output is correct |
21 |
Correct |
5 ms |
512 KB |
Output is correct |
22 |
Correct |
5 ms |
512 KB |
Output is correct |
23 |
Correct |
7 ms |
512 KB |
Output is correct |
24 |
Correct |
6 ms |
512 KB |
Output is correct |
25 |
Correct |
6 ms |
512 KB |
Output is correct |
26 |
Correct |
6 ms |
512 KB |
Output is correct |
27 |
Correct |
6 ms |
512 KB |
Output is correct |
28 |
Correct |
6 ms |
512 KB |
Output is correct |
29 |
Correct |
7 ms |
384 KB |
Output is correct |
30 |
Correct |
6 ms |
512 KB |
Output is correct |
31 |
Correct |
6 ms |
512 KB |
Output is correct |
32 |
Correct |
6 ms |
512 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
6 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
4 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
4 ms |
384 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Correct |
4 ms |
384 KB |
Output is correct |
10 |
Correct |
5 ms |
384 KB |
Output is correct |
11 |
Correct |
5 ms |
384 KB |
Output is correct |
12 |
Correct |
4 ms |
384 KB |
Output is correct |
13 |
Correct |
4 ms |
384 KB |
Output is correct |
14 |
Correct |
5 ms |
512 KB |
Output is correct |
15 |
Correct |
7 ms |
512 KB |
Output is correct |
16 |
Correct |
5 ms |
384 KB |
Output is correct |
17 |
Correct |
6 ms |
512 KB |
Output is correct |
18 |
Correct |
5 ms |
512 KB |
Output is correct |
19 |
Correct |
5 ms |
448 KB |
Output is correct |
20 |
Correct |
6 ms |
512 KB |
Output is correct |
21 |
Correct |
5 ms |
512 KB |
Output is correct |
22 |
Correct |
5 ms |
512 KB |
Output is correct |
23 |
Correct |
7 ms |
512 KB |
Output is correct |
24 |
Correct |
6 ms |
512 KB |
Output is correct |
25 |
Correct |
6 ms |
512 KB |
Output is correct |
26 |
Correct |
6 ms |
512 KB |
Output is correct |
27 |
Correct |
6 ms |
512 KB |
Output is correct |
28 |
Correct |
6 ms |
512 KB |
Output is correct |
29 |
Correct |
7 ms |
384 KB |
Output is correct |
30 |
Correct |
6 ms |
512 KB |
Output is correct |
31 |
Correct |
6 ms |
512 KB |
Output is correct |
32 |
Correct |
6 ms |
512 KB |
Output is correct |
33 |
Correct |
117 ms |
11724 KB |
Output is correct |
34 |
Correct |
134 ms |
12132 KB |
Output is correct |
35 |
Correct |
123 ms |
11752 KB |
Output is correct |
36 |
Correct |
122 ms |
12260 KB |
Output is correct |
37 |
Correct |
127 ms |
12644 KB |
Output is correct |
38 |
Correct |
122 ms |
12392 KB |
Output is correct |
39 |
Correct |
157 ms |
11372 KB |
Output is correct |
40 |
Correct |
158 ms |
11372 KB |
Output is correct |
41 |
Correct |
157 ms |
11504 KB |
Output is correct |
42 |
Correct |
155 ms |
11372 KB |
Output is correct |
43 |
Correct |
156 ms |
11372 KB |
Output is correct |
44 |
Correct |
131 ms |
9580 KB |
Output is correct |
45 |
Correct |
133 ms |
9704 KB |
Output is correct |
46 |
Correct |
146 ms |
9576 KB |
Output is correct |
47 |
Correct |
121 ms |
11628 KB |
Output is correct |
48 |
Correct |
128 ms |
11628 KB |
Output is correct |
49 |
Correct |
159 ms |
11628 KB |
Output is correct |
50 |
Correct |
162 ms |
11628 KB |
Output is correct |
51 |
Correct |
168 ms |
11628 KB |
Output is correct |
52 |
Correct |
159 ms |
11628 KB |
Output is correct |
53 |
Correct |
159 ms |
11628 KB |
Output is correct |