#include <bits/stdc++.h>
#define pp push
#define mp make_pair
#define ff first
#define ss second
#define pb push_back
using namespace std;
pair<int,int>p[200005];
pair<int,int>h[200005];
int dpf[200005];
int dpl[200005];
vector<pair<int,int> >v;
int main(){
int n;
cin >> n;
for(int i=1;i<=n+1;i++){
int a;
cin >> a;
p[i]=mp(a,i);
}
for(int i=1;i<=n;i++){
int a;
cin >> a;
h[i]=mp(a,i);
}
sort(p+1,p+n+2);
sort(h+1,h+n+1);
dpf[0]=0;
for(int i=1;i<=n;i++){
int a=p[i].ff;
int b=h[i].ff;
dpf[i]=max(dpf[i-1],a-b);
}
dpl[n+1]=0;
for(int i=n;i>=1;i--){
int a=p[i+1].ff;
int b=h[i].ff;
dpl[i]=max(dpl[i+1],a-b);
}
for(int i=1;i<=n+1;i++){
v.pb(mp(p[i].ss,max(dpf[i-1],dpl[i])));
}
sort(v.begin(),v.end());
for(int i=0;i<v.size();i++){
cout << v[i].ss << ' ';
}
}
Compilation message
ho_t1.cpp: In function 'int main()':
ho_t1.cpp:44:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
44 | for(int i=0;i<v.size();i++){
| ~^~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
0 ms |
384 KB |
Output is correct |
12 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
0 ms |
384 KB |
Output is correct |
12 |
Correct |
1 ms |
384 KB |
Output is correct |
13 |
Correct |
1 ms |
384 KB |
Output is correct |
14 |
Correct |
2 ms |
384 KB |
Output is correct |
15 |
Correct |
3 ms |
512 KB |
Output is correct |
16 |
Correct |
1 ms |
384 KB |
Output is correct |
17 |
Correct |
4 ms |
512 KB |
Output is correct |
18 |
Correct |
4 ms |
512 KB |
Output is correct |
19 |
Correct |
4 ms |
512 KB |
Output is correct |
20 |
Correct |
4 ms |
512 KB |
Output is correct |
21 |
Correct |
4 ms |
512 KB |
Output is correct |
22 |
Correct |
4 ms |
512 KB |
Output is correct |
23 |
Correct |
4 ms |
512 KB |
Output is correct |
24 |
Correct |
4 ms |
512 KB |
Output is correct |
25 |
Correct |
4 ms |
512 KB |
Output is correct |
26 |
Correct |
4 ms |
512 KB |
Output is correct |
27 |
Correct |
4 ms |
512 KB |
Output is correct |
28 |
Correct |
4 ms |
512 KB |
Output is correct |
29 |
Correct |
3 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 |
444 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
0 ms |
384 KB |
Output is correct |
12 |
Correct |
1 ms |
384 KB |
Output is correct |
13 |
Correct |
1 ms |
384 KB |
Output is correct |
14 |
Correct |
2 ms |
384 KB |
Output is correct |
15 |
Correct |
3 ms |
512 KB |
Output is correct |
16 |
Correct |
1 ms |
384 KB |
Output is correct |
17 |
Correct |
4 ms |
512 KB |
Output is correct |
18 |
Correct |
4 ms |
512 KB |
Output is correct |
19 |
Correct |
4 ms |
512 KB |
Output is correct |
20 |
Correct |
4 ms |
512 KB |
Output is correct |
21 |
Correct |
4 ms |
512 KB |
Output is correct |
22 |
Correct |
4 ms |
512 KB |
Output is correct |
23 |
Correct |
4 ms |
512 KB |
Output is correct |
24 |
Correct |
4 ms |
512 KB |
Output is correct |
25 |
Correct |
4 ms |
512 KB |
Output is correct |
26 |
Correct |
4 ms |
512 KB |
Output is correct |
27 |
Correct |
4 ms |
512 KB |
Output is correct |
28 |
Correct |
4 ms |
512 KB |
Output is correct |
29 |
Correct |
3 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 |
444 KB |
Output is correct |
33 |
Correct |
406 ms |
11772 KB |
Output is correct |
34 |
Correct |
413 ms |
12260 KB |
Output is correct |
35 |
Correct |
397 ms |
11748 KB |
Output is correct |
36 |
Correct |
405 ms |
12132 KB |
Output is correct |
37 |
Correct |
415 ms |
12516 KB |
Output is correct |
38 |
Correct |
408 ms |
12700 KB |
Output is correct |
39 |
Correct |
407 ms |
11492 KB |
Output is correct |
40 |
Correct |
400 ms |
11548 KB |
Output is correct |
41 |
Correct |
408 ms |
11748 KB |
Output is correct |
42 |
Correct |
410 ms |
11492 KB |
Output is correct |
43 |
Correct |
403 ms |
11492 KB |
Output is correct |
44 |
Correct |
397 ms |
10960 KB |
Output is correct |
45 |
Correct |
398 ms |
11236 KB |
Output is correct |
46 |
Correct |
398 ms |
11144 KB |
Output is correct |
47 |
Correct |
418 ms |
11244 KB |
Output is correct |
48 |
Correct |
414 ms |
11236 KB |
Output is correct |
49 |
Correct |
418 ms |
11748 KB |
Output is correct |
50 |
Correct |
415 ms |
11876 KB |
Output is correct |
51 |
Correct |
416 ms |
12016 KB |
Output is correct |
52 |
Correct |
413 ms |
11876 KB |
Output is correct |
53 |
Correct |
421 ms |
11804 KB |
Output is correct |