#include<bits/stdc++.h>
using namespace std;
#define xx first
#define yy second
//3 4 6 7
//2 4 6
//3 4 7
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n;
cin>>n;
vector<pair<int,int>> a(n+1), b(n);
for(int i=0;i<n+1;++i) {
cin>>a[i].xx;
a[i].yy=i;
}
for(int i=0;i<n;++i) {
cin>>b[i].xx;
b[i].yy=i;
}
sort(b.begin(),b.end());
for(int i=0;i<n+1;++i) {
vector<int> lst;
for(int j=0;j<n+1;++j) if(i!=j) lst.push_back(a[j].xx);
sort(lst.begin(),lst.end());
int mx=0;
for(int j=0;j<n;++j) mx=max(mx, max(0, lst[j]-b[j].xx));
cout<<mx<<" \n"[i==n];
}
//~ sort(a.begin(),a.end());
//~ sort(b.begin(),b.end());
//~ vector<int> pre(n+1);
//~ vector<int> suf(n+1);
//~ for(int i=0;i<n;++i) {
//~ pre[i]=max(0, a[i+1].xx-b[i].xx);
//~ suf[i+1]=max(0, a[i].xx-b[i].xx);
//~ }
//~ for(int i=n-1;i>=0;i--) pre[i]=max(pre[i], pre[i+1]);
//~ for(int i=1;i<n+1;i++) suf[i]=max(suf[i], suf[i-1]);
//~ for(auto i:pre) {
//~ cerr<<i<<" ";
//~ }cerr<<"\n";
//~ for(auto i:suf) {
//~ cerr<<i<<" ";
//~ }cerr<<"\n";
//~ vector<int> ans=pre;
//~ for(int i=n;i>=0;i--) ans[i]=max(ans[i], suf[i]);
//~ for(int i=0;i<n+1;++i) cout<<ans[a[i].yy]<<" \n"[i==n];
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
380 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Correct |
5 ms |
376 KB |
Output is correct |
6 |
Correct |
5 ms |
376 KB |
Output is correct |
7 |
Correct |
5 ms |
376 KB |
Output is correct |
8 |
Correct |
5 ms |
376 KB |
Output is correct |
9 |
Correct |
5 ms |
376 KB |
Output is correct |
10 |
Correct |
5 ms |
376 KB |
Output is correct |
11 |
Correct |
5 ms |
376 KB |
Output is correct |
12 |
Correct |
5 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
380 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Correct |
5 ms |
376 KB |
Output is correct |
6 |
Correct |
5 ms |
376 KB |
Output is correct |
7 |
Correct |
5 ms |
376 KB |
Output is correct |
8 |
Correct |
5 ms |
376 KB |
Output is correct |
9 |
Correct |
5 ms |
376 KB |
Output is correct |
10 |
Correct |
5 ms |
376 KB |
Output is correct |
11 |
Correct |
5 ms |
376 KB |
Output is correct |
12 |
Correct |
5 ms |
376 KB |
Output is correct |
13 |
Correct |
6 ms |
376 KB |
Output is correct |
14 |
Correct |
35 ms |
376 KB |
Output is correct |
15 |
Correct |
101 ms |
504 KB |
Output is correct |
16 |
Correct |
6 ms |
376 KB |
Output is correct |
17 |
Correct |
188 ms |
376 KB |
Output is correct |
18 |
Correct |
121 ms |
376 KB |
Output is correct |
19 |
Correct |
129 ms |
376 KB |
Output is correct |
20 |
Correct |
127 ms |
376 KB |
Output is correct |
21 |
Correct |
134 ms |
376 KB |
Output is correct |
22 |
Correct |
123 ms |
504 KB |
Output is correct |
23 |
Correct |
126 ms |
376 KB |
Output is correct |
24 |
Correct |
133 ms |
376 KB |
Output is correct |
25 |
Correct |
186 ms |
504 KB |
Output is correct |
26 |
Correct |
169 ms |
376 KB |
Output is correct |
27 |
Correct |
168 ms |
504 KB |
Output is correct |
28 |
Correct |
187 ms |
376 KB |
Output is correct |
29 |
Correct |
134 ms |
376 KB |
Output is correct |
30 |
Correct |
172 ms |
376 KB |
Output is correct |
31 |
Correct |
193 ms |
380 KB |
Output is correct |
32 |
Correct |
210 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
380 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Correct |
5 ms |
376 KB |
Output is correct |
6 |
Correct |
5 ms |
376 KB |
Output is correct |
7 |
Correct |
5 ms |
376 KB |
Output is correct |
8 |
Correct |
5 ms |
376 KB |
Output is correct |
9 |
Correct |
5 ms |
376 KB |
Output is correct |
10 |
Correct |
5 ms |
376 KB |
Output is correct |
11 |
Correct |
5 ms |
376 KB |
Output is correct |
12 |
Correct |
5 ms |
376 KB |
Output is correct |
13 |
Correct |
6 ms |
376 KB |
Output is correct |
14 |
Correct |
35 ms |
376 KB |
Output is correct |
15 |
Correct |
101 ms |
504 KB |
Output is correct |
16 |
Correct |
6 ms |
376 KB |
Output is correct |
17 |
Correct |
188 ms |
376 KB |
Output is correct |
18 |
Correct |
121 ms |
376 KB |
Output is correct |
19 |
Correct |
129 ms |
376 KB |
Output is correct |
20 |
Correct |
127 ms |
376 KB |
Output is correct |
21 |
Correct |
134 ms |
376 KB |
Output is correct |
22 |
Correct |
123 ms |
504 KB |
Output is correct |
23 |
Correct |
126 ms |
376 KB |
Output is correct |
24 |
Correct |
133 ms |
376 KB |
Output is correct |
25 |
Correct |
186 ms |
504 KB |
Output is correct |
26 |
Correct |
169 ms |
376 KB |
Output is correct |
27 |
Correct |
168 ms |
504 KB |
Output is correct |
28 |
Correct |
187 ms |
376 KB |
Output is correct |
29 |
Correct |
134 ms |
376 KB |
Output is correct |
30 |
Correct |
172 ms |
376 KB |
Output is correct |
31 |
Correct |
193 ms |
380 KB |
Output is correct |
32 |
Correct |
210 ms |
376 KB |
Output is correct |
33 |
Execution timed out |
1090 ms |
5348 KB |
Time limit exceeded |
34 |
Halted |
0 ms |
0 KB |
- |