Submission #762899

#TimeUsernameProblemLanguageResultExecution timeMemory
762899adaawfJust Long Neckties (JOI20_ho_t1)C++14
100 / 100
184 ms6988 KiB
#include <iostream> #include <algorithm> using namespace std; pair<int, int> a[200005]; int b[200005], c[200005], f[200005], res[200005]; int main() { int n; cin >> n; for (int i = 1; i <= n + 1; i++) { cin >> a[i].first; a[i].second = i; } for (int i = 1; i <= n; i++) { cin >> b[i]; } sort(a + 1, a + n + 2); sort(b + 1, b + n + 1); for (int i = 1; i <= n; i++) { c[i] = max(c[i - 1], a[i].first - b[i]); //cout << c[i] << " "; } for (int i = n + 1; i >= 2; i--) { f[i] = max(f[i + 1], a[i].first - b[i - 1]); } for (int i = 1; i <= n + 1; i++) { res[a[i].second] = max(c[i - 1], f[i + 1]); } for (int i = 1; i <= n + 1; i++) cout << res[i] << " "; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...