제출 #1238146

#제출 시각아이디문제언어결과실행 시간메모리
1238146nasjesJust Long Neckties (JOI20_ho_t1)C++20
100 / 100
253 ms11560 KiB
#include <iostream> #include <iomanip> #include <vector> #include <cmath> #include <algorithm> #include <set> #include <queue> #include <map> #include <stack> #include <bitset> #include <string> #include <cstring> #include <iterator> #include <random> using namespace std; typedef long long ll; typedef pair<ll, ll> pll; typedef long double ld; const ll dim = 5*1e6+7; //const ll mod = 1e9 + 7; const ll inf = 1e18 + 77; #define endl "\n" #define fi first #define pb push_back #define se second #define vll vector<ll> ll n, m; pll a[dim]; ll op1[dim], op2[dim], ans[dim]; ll b[dim]; int main() { ll k, t, u0, v0; string s1; cin>>n; for(int i=1; i<=n+1; i++) { cin >> a[i].fi; a[i].se=i; op1[i]=0; op2[i]=0; } for(int j=1; j<=n; j++){ cin>>b[j]; } sort(a+1, a+1+n+1); sort(b+1, b+1+n); for(int i=1; i<=n; i++){ op1[i]=max(op1[i-1], max<ll>(0, a[i].fi-b[i])); } op2[n+1]=0; for(int i=n; i>=1; i--){ op2[i]=max(op2[i+1], max<ll>(a[i+1].fi-b[i], 0)); } for(int i=1; i<=n+1; i++){ ans[a[i].se]=max(op1[i-1], op2[i]); // cout<<op1[i-1]<<" "<<op2[i]<<endl; } for(int i=1; i<=n+1; i++){ cout<<ans[i]<<" "; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...