제출 #1083335

#제출 시각아이디문제언어결과실행 시간메모리
1083335vjudge1Just Long Neckties (JOI20_ho_t1)C++17
100 / 100
167 ms19384 KiB
#include <bits/stdc++.h> //#ifndef ONLINE_JUDGE //#include <debugging.h> //#endif #define ff first #define ss second #define pp push_back #define all(x) (x).begin(),(x).end() #define dbg(v) cout << "Line(" << __LINE__ << ") -> " << #v << " = " << (v) << endl; using namespace std; using ll = long long; using ld = long double; using pii = pair <int,int>; using pll = pair <ll,ll>; using pld = pair <ld,ld>; const char el ='\n'; const char sp = ' '; const int maxn = 2e5+5, mod = 1e9+7, N = 10; const ll inf = 1e18L+3; int n,a[maxn],b[maxn],c[maxn],l[maxn],r[maxn]; map <int,int> ans; void input() { cin>>n; for(int i=1;i<=n+1;++i) cin>>a[i]; for(int i=1;i<=n+1;++i) c[i]=a[i]; for(int i=1;i<=n;++i) cin>>b[i]; sort(a+1,a+n+2); sort(b+1,b+n+1); } void solve() { for(int i=1;i<=n;++i) l[i] = max(l[i-1],a[i]-b[i]); for(int i=n+1;i>1;--i) r[i] = max(r[i+1],a[i]-b[i-1]); for(int i=1;i<=n+1;++i) ans[a[i]] = max(l[i-1],r[i+1]); for(int i=1;i<=n+1;++i) cout<<ans[c[i]]<<sp; } int32_t main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int test = 1; // cin>>test; while(test-->0) { input(); solve(); } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...