Submission #1100222

#TimeUsernameProblemLanguageResultExecution timeMemory
1100222owieczkaJust Long Neckties (JOI20_ho_t1)C++17
100 / 100
75 ms10104 KiB
#include <bits/stdc++.h>
using namespace std;

pair<int, int> neckties[200'005];
int employees[200'005];
int strangeness[200'005];
int ans[200'005];

int main()
{
   ios_base::sync_with_stdio(0); cin.tie(0);
   int n;
   cin >> n;
   for (int i = 0; i <= n; i++)
   {
      cin >> neckties[i].first;
      neckties[i].second = i;
   }
   for (int i = 0; i < n; i++)
   {
      cin >> employees[i];
   }
   sort (neckties, neckties + n + 1);
   sort (employees, employees + n);
   for (int i = n+1; i > 0; i--)
   {
      strangeness[i] = max(strangeness[i+1], neckties[i].first - employees[i-1]);
   }
   int str = 0;
   for (int i = 0; i <= n; i++)
   {
      ans[neckties[i].second] = max (str, strangeness[i+1]);
      str = max(str, neckties[i].first - employees[i]);
   }
   for (int i = 0; i <= n; i++)
   {
      cout << ans[i] << ' ';
   }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...