#include <bits/stdc++.h>
using namespace std;
#define int long long
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);
#define OYY 1000000005
#define mod 998244353
#define mid (start+end)/2
vector <pair<int,int>> v,v2,hu,d;
int re[1000005],tree[8000005],tut[1000005];
void build(int node,int start,int end){
if(start==end){
tree[node]=re[start];
return ;
}
build(node*2,start,mid),build(node*2+1,mid+1,end);
tree[node]=max(tree[node*2],tree[node*2+1]);
}
int query(int node,int start,int end,int l,int r){
if(start>end || start>r || end<l)return 0;
if(start>=l&& end<=r)return tree[node];
return max(query(node*2,start,mid,l,r),query(node*2+1,mid+1,end,l,r));
}
void update(int node,int start,int end,int l,int r,int val){
if(start>end || start>r || end<l)return ;
if(start>=l&& end<=r){
tree[node]=val;
return ;
}
update(node*2,start,mid,l,r,val),update(node*2+1,mid+1,end,l,r,val);
tree[node]=max(tree[node*2],tree[node*2+1]);
}
int32_t main(){
faster
int n;cin>>n;
int dizi[n+1],di[n];
for(int i=0;i<=n;i++){
cin>>dizi[i];
d.push_back({dizi[i],i});
}
for(int i=0;i<n;i++)cin>>di[i];
sort(d.begin(),d.end());
sort(di,di+n);
sort(dizi,dizi+n);
int maxi=0;
for(int i=1;i<=n;i++){
// cout<<dizi[i]<<" "<<di[]
v.push_back({max(d[i].first-di[i-1],(int)0),d[i].second});
maxi=max(maxi,v[i-1].first);
}
for(int i=0;i<n;i++){
v2.push_back({max(d[i].first-di[i],(int)0),d[i].second});
}
for(int i=0;i<v.size();i++){
// cout<<v[i].first<<" "<<v[i].second<<endl;
re[i+1]=v[i].first;
tut[i+1]=v[i].second;
// cout<<tut[i+1]<<endl;
}
//for(int i=0;i<n;i++)
build(1,1,n);
//cout<<d[0].second<<endl;
hu.push_back({d[0].second,maxi});
for(int i=0;i<v.size();i++){
update(1,1,n,i+1,i+1,v2[i].first);
hu.push_back({tut[i+1],query(1,1,n,1,n)});
}
sort(hu.begin(),hu.end());
for(int i=0;i<hu.size();i++)cout<<hu[i].second<<" ";
cout<<endl;
return 0;
}
Compilation message
ho_t1.cpp: In function 'int32_t main()':
ho_t1.cpp:57:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
57 | for(int i=0;i<v.size();i++){
| ~^~~~~~~~~
ho_t1.cpp:67:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
67 | for(int i=0;i<v.size();i++){
| ~^~~~~~~~~
ho_t1.cpp:72:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
72 | for(int i=0;i<hu.size();i++)cout<<hu[i].second<<" ";
| ~^~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
0 ms |
340 KB |
Output is correct |
8 |
Correct |
0 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
0 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
0 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
0 ms |
340 KB |
Output is correct |
8 |
Correct |
0 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
0 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
0 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
332 KB |
Output is correct |
14 |
Correct |
1 ms |
468 KB |
Output is correct |
15 |
Correct |
1 ms |
468 KB |
Output is correct |
16 |
Correct |
0 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
596 KB |
Output is correct |
18 |
Correct |
1 ms |
468 KB |
Output is correct |
19 |
Correct |
1 ms |
536 KB |
Output is correct |
20 |
Correct |
1 ms |
468 KB |
Output is correct |
21 |
Correct |
1 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 |
596 KB |
Output is correct |
26 |
Correct |
1 ms |
596 KB |
Output is correct |
27 |
Correct |
1 ms |
596 KB |
Output is correct |
28 |
Correct |
2 ms |
596 KB |
Output is correct |
29 |
Correct |
1 ms |
468 KB |
Output is correct |
30 |
Correct |
1 ms |
596 KB |
Output is correct |
31 |
Correct |
2 ms |
596 KB |
Output is correct |
32 |
Correct |
2 ms |
596 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
0 ms |
340 KB |
Output is correct |
8 |
Correct |
0 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
0 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
0 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
332 KB |
Output is correct |
14 |
Correct |
1 ms |
468 KB |
Output is correct |
15 |
Correct |
1 ms |
468 KB |
Output is correct |
16 |
Correct |
0 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
596 KB |
Output is correct |
18 |
Correct |
1 ms |
468 KB |
Output is correct |
19 |
Correct |
1 ms |
536 KB |
Output is correct |
20 |
Correct |
1 ms |
468 KB |
Output is correct |
21 |
Correct |
1 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 |
596 KB |
Output is correct |
26 |
Correct |
1 ms |
596 KB |
Output is correct |
27 |
Correct |
1 ms |
596 KB |
Output is correct |
28 |
Correct |
2 ms |
596 KB |
Output is correct |
29 |
Correct |
1 ms |
468 KB |
Output is correct |
30 |
Correct |
1 ms |
596 KB |
Output is correct |
31 |
Correct |
2 ms |
596 KB |
Output is correct |
32 |
Correct |
2 ms |
596 KB |
Output is correct |
33 |
Correct |
137 ms |
25440 KB |
Output is correct |
34 |
Correct |
142 ms |
26148 KB |
Output is correct |
35 |
Correct |
139 ms |
25552 KB |
Output is correct |
36 |
Correct |
140 ms |
25736 KB |
Output is correct |
37 |
Correct |
147 ms |
26144 KB |
Output is correct |
38 |
Correct |
139 ms |
25956 KB |
Output is correct |
39 |
Correct |
137 ms |
25740 KB |
Output is correct |
40 |
Correct |
159 ms |
25712 KB |
Output is correct |
41 |
Correct |
154 ms |
25908 KB |
Output is correct |
42 |
Correct |
137 ms |
25768 KB |
Output is correct |
43 |
Correct |
145 ms |
25812 KB |
Output is correct |
44 |
Correct |
145 ms |
25416 KB |
Output is correct |
45 |
Correct |
137 ms |
25552 KB |
Output is correct |
46 |
Correct |
134 ms |
25492 KB |
Output is correct |
47 |
Correct |
127 ms |
26244 KB |
Output is correct |
48 |
Correct |
124 ms |
26176 KB |
Output is correct |
49 |
Correct |
156 ms |
26232 KB |
Output is correct |
50 |
Correct |
141 ms |
26204 KB |
Output is correct |
51 |
Correct |
144 ms |
26416 KB |
Output is correct |
52 |
Correct |
156 ms |
26172 KB |
Output is correct |
53 |
Correct |
141 ms |
26192 KB |
Output is correct |