Submission #529786

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
5297862022-02-23 16:31:41Alex_tz307Just Long Neckties (JOI20_ho_t1)C++17
100 / 100
88 ms10052 KiB
#include <bits/stdc++.h>
using namespace std;
void testCase() {
int n;
cin >> n;
vector<pair<int, int>> a(n + 2);
for (int i = 1; i <= n + 1; ++i) {
cin >> a[i].first;
a[i].second = i;
}
sort(a.begin() + 1, a.end());
vector<int> b(n + 2);
for (int i = 1; i <= n; ++i) {
cin >> b[i];
}
sort(b.begin() + 1, b.begin() + n + 1);
vector<int> sufMax(n + 2);
for (int i = n; i > 0; --i) {
sufMax[i] = max(a[i + 1].first - b[i], sufMax[i + 1]);
}
vector<int> sol(n + 2);
int pref = 0;
for (int i = 1; i <= n + 1; ++i) {
sol[a[i].second] = max(pref, sufMax[i]);
pref = max(pref, a[i].first - b[i]);
}
for (int i = 1; i <= n + 1; ++i) {
cout << sol[i] << ' ';
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...