#include <bits/stdc++.h>
using namespace std;
#define int long long
#define F first
#define S second
#define el endl
#define cout(x) for(auto v:x)cout<<v<<' '
#define cin(x) for(auto &v:x)cin>>v;
#define pb(x) push_back(x)
#define all(x) x.begin(),x.end()
int32_t main()
{
int n;cin>>n;
vector<pair<int,int>>v;
int b[n];
for(int i=0;i<=n;i++){
int x;cin>>x;
v.push_back({x,i});
}
sort(all(v));
cin(b);
sort(b,b+n);
multiset<int>s;
for(int i=0;i<n;i++){
// cout<<b[i]<<' '<<v[i].F<<el;
s.insert(v[i].F-b[i]);
}
int ans[n+1]={};
ans[v[n].S]=*max_element(s.begin(),s.end());
for(int i=n-1;i>=0;i--){
s.erase(s.find(v[i].F-b[i]));
s.insert(v[i+1].F-b[i]);
ans[v[i].S]=*max_element(s.begin(),s.end());
}
cout(ans);
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 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 |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 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 |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
6 ms |
340 KB |
Output is correct |
15 |
Correct |
15 ms |
436 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
27 ms |
464 KB |
Output is correct |
18 |
Correct |
19 ms |
440 KB |
Output is correct |
19 |
Correct |
20 ms |
340 KB |
Output is correct |
20 |
Correct |
19 ms |
340 KB |
Output is correct |
21 |
Correct |
20 ms |
340 KB |
Output is correct |
22 |
Correct |
22 ms |
452 KB |
Output is correct |
23 |
Correct |
18 ms |
468 KB |
Output is correct |
24 |
Correct |
19 ms |
396 KB |
Output is correct |
25 |
Correct |
27 ms |
492 KB |
Output is correct |
26 |
Correct |
25 ms |
468 KB |
Output is correct |
27 |
Correct |
25 ms |
468 KB |
Output is correct |
28 |
Correct |
24 ms |
460 KB |
Output is correct |
29 |
Correct |
17 ms |
340 KB |
Output is correct |
30 |
Correct |
21 ms |
456 KB |
Output is correct |
31 |
Correct |
25 ms |
468 KB |
Output is correct |
32 |
Correct |
27 ms |
476 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 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 |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
6 ms |
340 KB |
Output is correct |
15 |
Correct |
15 ms |
436 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
27 ms |
464 KB |
Output is correct |
18 |
Correct |
19 ms |
440 KB |
Output is correct |
19 |
Correct |
20 ms |
340 KB |
Output is correct |
20 |
Correct |
19 ms |
340 KB |
Output is correct |
21 |
Correct |
20 ms |
340 KB |
Output is correct |
22 |
Correct |
22 ms |
452 KB |
Output is correct |
23 |
Correct |
18 ms |
468 KB |
Output is correct |
24 |
Correct |
19 ms |
396 KB |
Output is correct |
25 |
Correct |
27 ms |
492 KB |
Output is correct |
26 |
Correct |
25 ms |
468 KB |
Output is correct |
27 |
Correct |
25 ms |
468 KB |
Output is correct |
28 |
Correct |
24 ms |
460 KB |
Output is correct |
29 |
Correct |
17 ms |
340 KB |
Output is correct |
30 |
Correct |
21 ms |
456 KB |
Output is correct |
31 |
Correct |
25 ms |
468 KB |
Output is correct |
32 |
Correct |
27 ms |
476 KB |
Output is correct |
33 |
Execution timed out |
1092 ms |
18808 KB |
Time limit exceeded |
34 |
Halted |
0 ms |
0 KB |
- |