Submission #413577

#TimeUsernameProblemLanguageResultExecution timeMemory
413577OzyJust Long Neckties (JOI20_ho_t1)C++17
100 / 100
130 ms13868 KiB
#include <iostream> #include <bits/stdc++.h> using namespace std; #define rep(i,a,b) for (int i = (a); i <= (b); i++) #define repa(i,a,b) for (int i = (a); i >= (b); i--) #define lli long long int #define debugsl(a) cout << #a << " = " << a << ", " #define debug(a) cout << #a << " = " << a << endl #define MAX 200000 #define val first #define pos second lli n,paso,a,act; lli res[MAX+2],B[MAX+2],maximos[MAX+2]; pair<lli,lli> A[MAX+2]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n; rep(i,1,n+1) { cin >> A[i].val; A[i].pos = i;; } rep(i,1,n) cin >> B[i]; sort(A+1, A+2+n); sort(B+1,B+n+1); rep(i,1,n) { a = max(A[i].val - B[i], 0ll); maximos[i] = max(a,maximos[i-1]); } res[A[n+1].pos] = maximos[n]; act = 0; repa(i,n,1) { a = max(A[i+1].val - B[i], 0ll); act = max(act,a); res[A[i].pos] = max(act,maximos[i-1]); } rep(i,1,n+1) cout << res[i] << ' '; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...