이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"
#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
void solve(){
int n;
cin >> n;
vector<int> a(n + 1),b(n);
for(int i = 0; i < n + 1; i++){
cin >> a[i];
}
for(int i = 0; i < n; i++){
cin >> b[i];
}
sort(all(a)); sort(all(b));
vector<int> one(n + 1),two(n + 2);
for(int i = 0; i < n; i++){
one[i] = max((i > 0 ? one[i - 1] : 0),a[i] - b[i]);
}
for(int i = n; i >= 1; i--){
two[i] = max(two[i + 1],a[i] - b[i - 1]);
}
for(int i = 0; i < n + 1; i++){
cout << max((i + 1 < n + 1 ? two[i + 1] : 0),(i > 0 ? one[i - 1] : 0)) << ' ';
}
}
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
int t = 1;
// cin >> t;
while(t--)
solve();
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |