#ifdef MINHDEPTRAI
#include "/Library/Developer/CommandLineTools/usr/include/c++/v1/bits/stdc++.h"
#include <chrono>
#define __gcd(a, b) gcd(a, b)
using namespace std ::chrono;
#else
#include <bits/stdc++.h>
#endif
using namespace std;
#define foru(i, a, b) for(int i = a; i <= b; ++i)
#define ford(i, a, b) for(int i = a; i >= b; --i)
#define IOS ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mp(a, b) make_pair(a, b)
#define endl '\n'
#define int long long
const int maxN = 1e6+ 5;
const int mod = 998244353;
const long long inf = 1e17;
int n, arr[maxN], b[maxN];
int prefix[maxN], suffix[maxN];
bool used[maxN];
signed main(){
// freopen("input.txt", "r", stdin);
// freopen("output2.txt", "w", stdout);
// input
IOS
cin >> n;
foru(i, 1, n + 1) {
cin >> arr[i];
}
foru(i, 1, n){
cin >> b[i];
}
sort(arr + 1, arr + 2 + n);
sort(b + 1, b + 1 + n);
prefix[0] = 0;
foru(i, 1, n){
prefix[i] = max( prefix[i - 1], arr[i] - b[i]);
}
suffix[n + 1] = 0;
ford(i, n, 1){
suffix[i] = max(suffix[i + 1], arr[i + 1] - b[i]);
}
int ans = 0;
foru(i, 1, n + 1){
cout << max(prefix[i - 1], suffix[i]) << " ";
}
}
Compilation message
ho_t1.cpp: In function 'int main()':
ho_t1.cpp:52:9: warning: unused variable 'ans' [-Wunused-variable]
52 | int ans = 0;
| ^~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |