제출 #765635

#제출 시각아이디문제언어결과실행 시간메모리
765635NK_Just Long Neckties (JOI20_ho_t1)C++17
0 / 100
1 ms212 KiB
// Success consists of going from failure to failure without loss of enthusiasm #include <bits/stdc++.h> using namespace std; #define nl '\n' template<class T> using V = vector<T>; const int INF = int(1e9) + 10; int main() { cin.tie(0)->sync_with_stdio(0); int N; cin >> N; V<int> A(N + 1); for(auto& x : A) cin >> x; V<int> B(N); for(auto& x : B) cin >> x; sort(begin(A), end(A)); sort(begin(B), end(B)); V<int> P(N + 1, 0); for(int i = 0; i < N; i++) P[i] = max(A[i] - B[i], (i-1 >= 0 ? P[i-1] : 0)); V<int> S(N + 1, 0); for(int i = N; i >= 1; i--) S[i] = max(A[i] - B[i-1], (i+1 <= N ? S[i+1] : 0)); // for(auto x : P) cout << x << " "; // cout << nl; // for(auto x : S) cout << x << " "; // cout << nl; for(int i = 0; i <= N; i++) { int ans = 0; if (i-1 >= 0) ans = max(ans, P[i - 1]); if (i+1 <= N) ans = max(ans, S[i + 1]); cout << ans << " "; } cout << nl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...