Submission #998280

#TimeUsernameProblemLanguageResultExecution timeMemory
998280vicvicJust Long Neckties (JOI20_ho_t1)C++11
100 / 100
196 ms10112 KiB
#include <iostream> #include <fstream> #include <climits> #include <cstring> #include <algorithm> using namespace std; const int nmax=2e5+5; int n, v[nmax], b[nmax], rez[nmax]; struct tie { int poz, val; } v1[nmax]; bool compare (tie a, tie b) { return a.val<b.val; } int main() { cin >> n; for (int i=1;i<=n+1;i++) { cin >> v[i]; v1[i]={i, v[i]}; } for (int i=1;i<=n;i++) { cin >> b[i]; } sort (b+1, b+n+1); sort (v1+1, v1+n+2, compare); int mx=0; for (int i=1;i<=n;i++) { mx=max (mx, max (0, v1[i].val-b[i])); } rez[v1[n+1].poz]=mx; for (int i=n;i>=1;i--) { mx=max (mx, max (0, v1[i+1].val-b[i])); rez[v1[i].poz]=mx; } for (int i=1;i<=n+1;i++) { cout << rez[i] << " "; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...