Submission #1114937

#TimeUsernameProblemLanguageResultExecution timeMemory
1114937AdamGSJust Long Neckties (JOI20_ho_t1)C++17
100 / 100
261 ms15552 KiB
#include<bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> t1(n + 1); vector<int> t2(n); vector<int> p; vector<int> t; for(int i = 0; i < n + 1; i++) { cin >> t1[i]; } vector<int> z = t1; for (int i = 0; i < n; i++) { cin >> t2[i]; } sort(t1.begin(), t1.end()); sort(t2.begin(), t2.end()); int m = 0; for (int i = 0; i < n; i++) { if (t1[i] - t2[i] > m) { m = t1[i] - t2[i]; } p.push_back(m); } m = 0; for (int i = n; i > 0; i--) { if (t1[i] - t2[i - 1] > m) { m = t1[i] - t2[i - 1]; } t.push_back(m); } reverse(t.begin(), t.end()); map<int, int> wyn; wyn[t1[0]] = t[0]; for (int i = 0; i < n - 1; i++) { wyn[t1[i + 1]] = max(p[i], t[i + 1]); } wyn[t1[n]] = p[p.size() - 1]; for (int i : z) { cout << wyn[i] << " "; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...