Submission #1275516

#TimeUsernameProblemLanguageResultExecution timeMemory
1275516kaiboyJust Long Neckties (JOI20_ho_t1)C++20
100 / 100
69 ms5360 KiB
#include <algorithm> #include <iostream> using namespace std; const int N = 200000; int aa[N + 1], ii[N + 1], bb[N], cc[N + 1]; int main() { ios_base::sync_with_stdio(false), cin.tie(NULL); int n; cin >> n; for (int i = 0; i <= n; i++) cin >> aa[ii[i] = i]; for (int i = 0; i < n; i++) cin >> bb[i]; sort(ii, ii + n + 1, [] (int i, int j) { return aa[i] < aa[j]; }); sort(bb, bb + n); int d = 0; for (int h = 0; h < n; h++) cc[ii[h + 1]] = max(cc[ii[h + 1]], d = max(d, aa[ii[h]] - bb[h])); d = 0; for (int h = n - 1; h >= 0; h--) cc[ii[h]] = max(cc[ii[h]], d = max(d, aa[ii[h + 1]] - bb[h])); for (int i = 0; i <= n; i++) cout << cc[i] << ' '; cout << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...