Submission #315336

#TimeUsernameProblemLanguageResultExecution timeMemory
315336DymoJust Long Neckties (JOI20_ho_t1)C++14
100 / 100
109 ms15608 KiB
#include<bits/stdc++.h> using namespace std; #define pb push_back #define ll long long #define pll pair<ll,ll> #define ff first #define ss second #define endl "\n" const ll maxn=5e5+50; const ll mod =1e9+7; const ll base=113; pll a[maxn]; ll l[maxn]; ll r[maxn]; ll b[maxn]; ll ans[maxn]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); if (fopen("GIDDY.inp", "r")) { freopen("GIDDY.inp", "r", stdin); freopen("GIDDY.out", "w", stdout) ; } ll n; cin>>n ; for (int i=1;i<=n+1;i++) { cin>>a[i].ff; a[i].ss=i; } sort(a+1,a+n+2); /* for (int i=1;i<=n+1;i++) { cout <<a[i].ff<<" "<<a[i].ss<<endl; }*/ for (int i=1;i<=n;i++) { cin>>b[i]; } sort(b+1,b+n+1); for (int i=1;i<=n;i++) { l[i]=max(l[i-1],max(0ll,a[i].ff-b[i])); } for (int i=n;i>=1;i--) { r[i]=max(r[i+1],max(0ll,a[i+1].ff-b[i])); } for (int i=1;i<=n+1;i++) { ans[a[i].ss]=max(l[i-1],r[i]); /* // cout <<l[i-1]<<" "<<r[i+1]<<" "<<i<<endl; }*/ } for (int i=1;i<=n+1;i++) { cout <<ans[i]<<" "; } }

Compilation message (stderr)

ho_t1.cpp: In function 'int main()':
ho_t1.cpp:28:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   28 |         freopen("GIDDY.inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
ho_t1.cpp:29:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   29 |         freopen("GIDDY.out", "w", stdout) ;
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...