Submission #1114817

#TimeUsernameProblemLanguageResultExecution timeMemory
1114817AdamGSJust Long Neckties (JOI20_ho_t1)C++17
0 / 100
1 ms336 KiB
#include<iostream> #include<vector> #include<algorithm> 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]; } 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()); cout << t[0] << " "; for (int i = 0; i < n - 1; i++) { cout << max(p[i], t[i + 1]) << " "; } cout << p[p.size() - 1]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...