#include<bits/stdc++.h>
using namespace std;
#define lalala ios_base::sync_with_stdio(false);cin.tie(NULL);
//#define endl "\n"
#define ll long long
#define pb push_back
#define N 200005
int main(){
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());
for(int i=0;i<n+1;i++){
ll int fark=0;
int gel=0;
//cout<<i<<" "<<arr[i].first<<endl;
for(int j=0;j<n;j++){
if(j==i)gel=1;
//cout<<arr[j+gel].first<<" "<<mus[j]<<" "<<j<<" "<<fark<<endl;
if(arr[j+gel].first<=mus[j])continue;
fark=max(fark,arr[j+gel].first-mus[j]);
}
cev[arr[i].second]=fark;
}
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 |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
300 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
300 KB |
Output is correct |
7 |
Correct |
1 ms |
296 KB |
Output is correct |
8 |
Correct |
0 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 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
300 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
300 KB |
Output is correct |
7 |
Correct |
1 ms |
296 KB |
Output is correct |
8 |
Correct |
0 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 |
2 ms |
340 KB |
Output is correct |
15 |
Correct |
5 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
6 ms |
340 KB |
Output is correct |
18 |
Correct |
5 ms |
308 KB |
Output is correct |
19 |
Correct |
5 ms |
424 KB |
Output is correct |
20 |
Correct |
5 ms |
340 KB |
Output is correct |
21 |
Correct |
5 ms |
340 KB |
Output is correct |
22 |
Correct |
5 ms |
340 KB |
Output is correct |
23 |
Correct |
5 ms |
340 KB |
Output is correct |
24 |
Correct |
5 ms |
312 KB |
Output is correct |
25 |
Correct |
7 ms |
340 KB |
Output is correct |
26 |
Correct |
7 ms |
340 KB |
Output is correct |
27 |
Correct |
5 ms |
424 KB |
Output is correct |
28 |
Correct |
5 ms |
340 KB |
Output is correct |
29 |
Correct |
7 ms |
340 KB |
Output is correct |
30 |
Correct |
6 ms |
312 KB |
Output is correct |
31 |
Correct |
6 ms |
312 KB |
Output is correct |
32 |
Correct |
6 ms |
308 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
300 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
300 KB |
Output is correct |
7 |
Correct |
1 ms |
296 KB |
Output is correct |
8 |
Correct |
0 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 |
2 ms |
340 KB |
Output is correct |
15 |
Correct |
5 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
6 ms |
340 KB |
Output is correct |
18 |
Correct |
5 ms |
308 KB |
Output is correct |
19 |
Correct |
5 ms |
424 KB |
Output is correct |
20 |
Correct |
5 ms |
340 KB |
Output is correct |
21 |
Correct |
5 ms |
340 KB |
Output is correct |
22 |
Correct |
5 ms |
340 KB |
Output is correct |
23 |
Correct |
5 ms |
340 KB |
Output is correct |
24 |
Correct |
5 ms |
312 KB |
Output is correct |
25 |
Correct |
7 ms |
340 KB |
Output is correct |
26 |
Correct |
7 ms |
340 KB |
Output is correct |
27 |
Correct |
5 ms |
424 KB |
Output is correct |
28 |
Correct |
5 ms |
340 KB |
Output is correct |
29 |
Correct |
7 ms |
340 KB |
Output is correct |
30 |
Correct |
6 ms |
312 KB |
Output is correct |
31 |
Correct |
6 ms |
312 KB |
Output is correct |
32 |
Correct |
6 ms |
308 KB |
Output is correct |
33 |
Execution timed out |
1069 ms |
11984 KB |
Time limit exceeded |
34 |
Halted |
0 ms |
0 KB |
- |