#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
#define f first
#define s second
#define pii pair<int,int>
#define piii pair<int,pair<int,int>>
#define vii vector<vector<int>>
#define vi vector<int>
#define cd complex<double>
#define endl '\n'
//#define multipletest
using namespace std;
const int LIM=2e5;
const int INF = 1e18;
const string name="template";
int n,m;
int a[LIM+5];
int b[LIM+5];
int ans[LIM+5];
void solve(){
//CODE GOES HERE
cin>>n;
for(int i=0;i<=n;++i){
cin>>a[i];
}
for(int i=0;i<n;++i){
cin>>b[i];
}
sort(b,b+n);
vector<int> v;
for(int i=0;i<=n;++i){
v.clear();
for(int j=0;j<=n;++j){
if(j!=i){
v.push_back(a[j]);
}
}
sort(v.begin(),v.end());
int mx=0;
for(int i=0;i<n;++i){
mx=max(mx,max(0ll,v[i]-b[i]));
}
ans[i]=mx;
}
for(int i=0;i<=n;++i){
cout<<ans[i]<<" ";
}
}
signed main(){
// freopen((name+".inp").c_str(),"r",stdin);
// freopen((name+".out").c_str(),"w",stdout);
// ifstream cin(".txt");
// ofstream cout(".txt");
//ifstream cin((name +".inp"));
//ofstream cout((name +".ans"));
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int test;
test=1;
#ifdef multipletest
cin>>test;
#endif
while(test--){
solve();
#ifdef DEBUG
cerr << "Runtime is: " << clock() * 1.0 / CLOCKS_PER_SEC << endl;
#endif
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 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 |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
340 KB |
Output is correct |
9 |
Correct |
0 ms |
340 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
340 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 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 |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
340 KB |
Output is correct |
9 |
Correct |
0 ms |
340 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
340 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
21 ms |
368 KB |
Output is correct |
15 |
Correct |
70 ms |
384 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
126 ms |
392 KB |
Output is correct |
18 |
Correct |
89 ms |
400 KB |
Output is correct |
19 |
Correct |
93 ms |
400 KB |
Output is correct |
20 |
Correct |
91 ms |
400 KB |
Output is correct |
21 |
Correct |
94 ms |
400 KB |
Output is correct |
22 |
Correct |
89 ms |
340 KB |
Output is correct |
23 |
Correct |
89 ms |
396 KB |
Output is correct |
24 |
Correct |
96 ms |
396 KB |
Output is correct |
25 |
Correct |
140 ms |
396 KB |
Output is correct |
26 |
Correct |
126 ms |
392 KB |
Output is correct |
27 |
Correct |
125 ms |
392 KB |
Output is correct |
28 |
Correct |
143 ms |
384 KB |
Output is correct |
29 |
Correct |
98 ms |
400 KB |
Output is correct |
30 |
Correct |
124 ms |
408 KB |
Output is correct |
31 |
Correct |
143 ms |
408 KB |
Output is correct |
32 |
Correct |
171 ms |
408 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 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 |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
340 KB |
Output is correct |
9 |
Correct |
0 ms |
340 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
340 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
21 ms |
368 KB |
Output is correct |
15 |
Correct |
70 ms |
384 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
126 ms |
392 KB |
Output is correct |
18 |
Correct |
89 ms |
400 KB |
Output is correct |
19 |
Correct |
93 ms |
400 KB |
Output is correct |
20 |
Correct |
91 ms |
400 KB |
Output is correct |
21 |
Correct |
94 ms |
400 KB |
Output is correct |
22 |
Correct |
89 ms |
340 KB |
Output is correct |
23 |
Correct |
89 ms |
396 KB |
Output is correct |
24 |
Correct |
96 ms |
396 KB |
Output is correct |
25 |
Correct |
140 ms |
396 KB |
Output is correct |
26 |
Correct |
126 ms |
392 KB |
Output is correct |
27 |
Correct |
125 ms |
392 KB |
Output is correct |
28 |
Correct |
143 ms |
384 KB |
Output is correct |
29 |
Correct |
98 ms |
400 KB |
Output is correct |
30 |
Correct |
124 ms |
408 KB |
Output is correct |
31 |
Correct |
143 ms |
408 KB |
Output is correct |
32 |
Correct |
171 ms |
408 KB |
Output is correct |
33 |
Execution timed out |
1064 ms |
5484 KB |
Time limit exceeded |
34 |
Halted |
0 ms |
0 KB |
- |