제출 #567064

#제출 시각아이디문제언어결과실행 시간메모리
567064MajidJust Long Neckties (JOI20_ho_t1)C++17
0 / 100
0 ms212 KiB
#include<bits/stdc++.h> using namespace std; //Types using ll = long long; using db = double; //Vectors #define pb push_back #define sz(vec) ((ll)vec.size()) #define all(vec) vec.begin(), vec.end() //things #define f first #define s second const int SMALLINF = 1e9 + 7; const ll BIGINF = ((ll)1e18) + 7; #define Speeed ios::sync_with_stdio(0);cin.tie(NULL); cout.tie(NULL); void solve(){ ll n; cin>>n; vector<pair<ll, ll> > a(n+1); vector<ll> b(n); for(ll i = 0; i < n+1; i++){ cin>>a[i].f; a[i].s = i; } for(ll i = 0; i < n; i++){ cin>>b[i]; } sort(all(a)); sort(all(b)); // vector<ll> prfx(n+1); // // for(ll i = n-1; i >= 0; i--){ // // prfx[i] = prfx[i+1] + (a[i+1] - a[i]); // } // // // for(ll i = 0; i < n; i++)cout<<prfx[i]<<" "; vector<ll> orig(n); ll mx = 0; for(ll i = n-1; i >= 0; i--){ orig[i] = max(0ll, a[i].f - b[i]); mx = max(mx, orig[i]); } // 3 // 3 4 6 7 // 2 4 6 // 4 // 1 8 12 17 20 // 3 7 10 13 vector<ll> ans(n+1), ch(n); for(ll i = n-1; i >= 0; i--){ ch[i] = max(0ll, a[i+1].f - b[i]); ans[a[i].s] = max(mx, ch[i]); } ans[a[n].s] = mx; for(ll i = 0; i < n+1; i++)cout<<ans[i]<<" "; } int main(){ Speeed ll t=1; // cin>>t; while(t--){ solve(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...