Submission #244843

#TimeUsernameProblemLanguageResultExecution timeMemory
244843NightlightJust Long Neckties (JOI20_ho_t1)C++14
0 / 100
5 ms384 KiB
#include <bits/stdc++.h> using namespace std; int N; int neck[200005]; int A[200005]; int bacc[200005]; int fron[200005]; int ans[200005]; int main() { ios_base::sync_with_stdio(0); cin >> N; for(int i = 1; i <= N + 1; i++) { cin >> neck[i]; } for(int i = 1; i <= N; i++) { cin >> A[i]; } sort(neck + 1, neck + N + 2); sort(A + 1, A + N + 1); for(int i = 1; i <= N; i++) { ans[i + 1] = max(neck[i] - A[i], 0); ans[i + 1] = max(ans[i], ans[i + 1]); } int bef = 0; for(int i = N; i > 0; i--) { bef = max(neck[i + 1] - A[i], bef); ans[i] = max(ans[i], bef); } for(int i = 1; i <= N + 1; i++) { cout << ans[i] << " "; } cin >> N; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...