Submission #698413

# Submission time Handle Problem Language Result Execution time Memory
698413 2023-02-13T11:58:20 Z dungz Just Long Neckties (JOI20_ho_t1) C++17
0 / 100
8 ms 6868 KB
#pragma GCC optimize ("O2")
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fo(i,a,b) for(ll i=a;i<=b;++i)
#define ff(i,a,b) for(ll i=a;i>=b;--i)
#define fi first
#define se second
#define endl '\n'
#define task "task"
#define task "task"
#define prll pair<ll,ll>
#define pb push_back
#define ld long double
const ll MIN=-1e18,MAX=1e18,MOD=1e9+7;
prll b[200005];
ll c[200005],mx1[200005],mx2[200005],h1[200005],h2[200005],ans[200005];
int main()
{
	#ifndef ONLINE_JUDGE
   		freopen (task".inp", "r", stdin);
   		freopen (task".out", "w", stdout);
	#endif
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll a;
    cin>>a;
    fo(i,1,a+1)
    {
        cin>>b[i].fi;
        b[i].se=i;
    }
    fo(i,1,a)
    {
        cin>>c[i];
    }
    sort(b+1,b+2+a);
    sort(c+1,c+1+a);
    fo(i,1,a)
    {
        h1[i]=max((ll)0,b[i].fi-c[i]);
        h2[i]=max((ll)0,b[i+1].fi-c[i]);
    }
    fo(i,1,a)
    {
        mx1[i]=max(h1[i],mx1[i-1]);
    }
    ff(i,a,1)
    {
        mx2[i]=max(h2[i],mx2[i+1]);
    }
    fo(i,1,a+1)
    {
        ans[b[i].se]=max(mx1[i-1],mx2[i]);
    }
    fo(i,1,a+1) cout<<ans[i]<<" ";
 }
/*
*/

Compilation message

ho_t1.cpp: In function 'int main()':
ho_t1.cpp:21:14: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |      freopen (task".inp", "r", stdin);
      |      ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
ho_t1.cpp:22:14: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |      freopen (task".out", "w", stdout);
      |      ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 8 ms 6868 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 8 ms 6868 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 8 ms 6868 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -