이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
//#pragma GCC optimize("Ofast,unroll-loops")
//#pragma GCC target("avx2,popcnt,lzcnt,abm,bmi,bmi2,fma,tune=native")
//#pragma expected_value
//#pragma isolated_call
//#pragma disjoint
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ld long double
#define pb push_back
#define setpre(i) setprecision(i)<<fixed
#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 mp make_pair
#define moo cout<<"moo "
#define fi first
#define se second
ll lmod = 1e9 + 7;
typedef vector<int> vi;
typedef vector< vector<int> > vvi;
typedef pair<int, int> ii;
typedef pair<double, double> dd;
ii arr[200002];
int a[200001];
int maxpref[2][200002];
int pos[200002];
int main(){
freopen("input.inp", "r", stdin);
// freopen("output.out", "w", stdout);
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int n; cin >> n;
foru(i, 1, n + 1){
int x; cin >> x;
arr[i] = mp(x, i);
}
foru(i, 1, n) cin >> a[i];
sort(arr + 1, arr + n + 2);
sort(a + 1, a + n + 1);
foru(i, 1, n + 1) pos[arr[i].se] = i;
maxpref[0][1] = arr[1].fi - a[1];
maxpref[1][n + 1] = arr[n + 1].fi - a[n];
foru(i, 1, n) maxpref[0][i] = max(maxpref[0][i - 1], arr[i].fi - a[i]);
ford(i, n + 1, 2) maxpref[1][i] = max(maxpref[1][i + 1], arr[i].fi - a[i - 1]);
// foru(i, 0, 1){
// foru(j, 1, n + 1) cout << maxpref[i][j] << " ";
// cout << endl;
// }
cout << maxpref[1][2] << " ";
foru(i, 2, n) cout << max(maxpref[0][pos[i] - 1], maxpref[1][pos[i] + 1]) << " ";
cout << maxpref[0][n];
// fclose(stdout);
}
컴파일 시 표준 에러 (stderr) 메시지
ho_t1.cpp: In function 'int main()':
ho_t1.cpp:34:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
34 | freopen("input.inp", "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |