#include<bits/stdc++.h>
using namespace std;
#define lalala ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define ll long long
#define pb push_back
#define N 200005
map<pair<int,int>,int>mp;
int main(){
lalala;
int n;cin>>n;
vector<pair<ll int,int>> arr;
vector<ll int> mus;
ll int cev[n+1];
for(int i=0;i<n+1;i++){
ll int a;cin>>a;
arr.pb({a,i});
}
for(int i=0;i<n;i++){
ll int a;cin>>a;
mus.pb(a);
}
sort(arr.begin(),arr.end());sort(mus.begin(),mus.end());
priority_queue<tuple<ll int ,int,int>> pq;
for(int i=0;i<n;i++){
if(mus[i]>arr[i+1].first){
pq.push({(ll int)0,i,i+1});
}
else pq.push({arr[i+1].first-mus[i],i,i+1});
}
ll int a,b,c;
tie(a,b,c)=pq.top();
cev[arr[0].second]=a;
for(int i=1;i<=n;i++){
pq.push({max(arr[i-1].first-mus[i-1],(ll int)0),i-1,i-1});
mp[{i-1,i}]=1;
tie(a,b,c)=pq.top();
while(mp[{b,c}]){
pq.pop();
tie(a,b,c)=pq.top();
}
cev[arr[i].second]=a;
}
for(int i=0;i<=n;i++)cout<<cev[i]<<" ";
cout<<endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 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 |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 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 |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
2 ms |
468 KB |
Output is correct |
16 |
Correct |
0 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
468 KB |
Output is correct |
18 |
Correct |
1 ms |
468 KB |
Output is correct |
19 |
Correct |
1 ms |
468 KB |
Output is correct |
20 |
Correct |
1 ms |
468 KB |
Output is correct |
21 |
Correct |
2 ms |
468 KB |
Output is correct |
22 |
Correct |
1 ms |
468 KB |
Output is correct |
23 |
Correct |
1 ms |
468 KB |
Output is correct |
24 |
Correct |
1 ms |
468 KB |
Output is correct |
25 |
Correct |
1 ms |
468 KB |
Output is correct |
26 |
Correct |
2 ms |
468 KB |
Output is correct |
27 |
Correct |
1 ms |
468 KB |
Output is correct |
28 |
Correct |
1 ms |
468 KB |
Output is correct |
29 |
Correct |
1 ms |
468 KB |
Output is correct |
30 |
Correct |
1 ms |
468 KB |
Output is correct |
31 |
Correct |
2 ms |
468 KB |
Output is correct |
32 |
Correct |
1 ms |
468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 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 |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
2 ms |
468 KB |
Output is correct |
16 |
Correct |
0 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
468 KB |
Output is correct |
18 |
Correct |
1 ms |
468 KB |
Output is correct |
19 |
Correct |
1 ms |
468 KB |
Output is correct |
20 |
Correct |
1 ms |
468 KB |
Output is correct |
21 |
Correct |
2 ms |
468 KB |
Output is correct |
22 |
Correct |
1 ms |
468 KB |
Output is correct |
23 |
Correct |
1 ms |
468 KB |
Output is correct |
24 |
Correct |
1 ms |
468 KB |
Output is correct |
25 |
Correct |
1 ms |
468 KB |
Output is correct |
26 |
Correct |
2 ms |
468 KB |
Output is correct |
27 |
Correct |
1 ms |
468 KB |
Output is correct |
28 |
Correct |
1 ms |
468 KB |
Output is correct |
29 |
Correct |
1 ms |
468 KB |
Output is correct |
30 |
Correct |
1 ms |
468 KB |
Output is correct |
31 |
Correct |
2 ms |
468 KB |
Output is correct |
32 |
Correct |
1 ms |
468 KB |
Output is correct |
33 |
Correct |
120 ms |
25600 KB |
Output is correct |
34 |
Correct |
121 ms |
30512 KB |
Output is correct |
35 |
Correct |
123 ms |
29480 KB |
Output is correct |
36 |
Correct |
120 ms |
30168 KB |
Output is correct |
37 |
Correct |
133 ms |
31072 KB |
Output is correct |
38 |
Correct |
122 ms |
30700 KB |
Output is correct |
39 |
Correct |
237 ms |
28968 KB |
Output is correct |
40 |
Correct |
235 ms |
28784 KB |
Output is correct |
41 |
Correct |
237 ms |
29164 KB |
Output is correct |
42 |
Correct |
255 ms |
29132 KB |
Output is correct |
43 |
Correct |
234 ms |
28844 KB |
Output is correct |
44 |
Correct |
156 ms |
25756 KB |
Output is correct |
45 |
Correct |
164 ms |
25932 KB |
Output is correct |
46 |
Correct |
155 ms |
25724 KB |
Output is correct |
47 |
Correct |
127 ms |
29224 KB |
Output is correct |
48 |
Correct |
122 ms |
29092 KB |
Output is correct |
49 |
Correct |
248 ms |
29780 KB |
Output is correct |
50 |
Correct |
243 ms |
29808 KB |
Output is correct |
51 |
Correct |
247 ms |
29732 KB |
Output is correct |
52 |
Correct |
248 ms |
29736 KB |
Output is correct |
53 |
Correct |
239 ms |
29812 KB |
Output is correct |