Submission #1067807

#TimeUsernameProblemLanguageResultExecution timeMemory
1067807BlueGlaucus1Just Long Neckties (JOI20_ho_t1)C++17
100 / 100
164 ms10916 KiB
#include <iostream> #include <algorithm> using namespace std; int n; pair<int, int> arr[200005]; int brr[200005]; int suffix[200005]; int prefix[200005]; int answer[200005]; int main(){ cin >> n; for(int i = 1;i<=n+1;i++){ cin >> arr[i].first; arr[i].second = i; } for(int i = 1;i<=n;i++){ cin >> brr[i]; } sort(arr+1, arr+n+2); sort(brr+1, brr+n+1); int maxi =0; for(int i = 1; i <= n;i++){ maxi = max(maxi, arr[i].first-brr[i]); prefix[i] = maxi; } maxi = 0; for(int i = n; i >=1;i--){ maxi = max(maxi, arr[i+1].first-brr[i]); suffix[i] = maxi; } for(int i =1 ; i <=n+1;i++){ answer[arr[i].second] = max(prefix[i-1], suffix[i]); } for(int i = 1; i<=n+1;i++){ cout << answer[i] << " "; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...