Submission #929093

# Submission time Handle Problem Language Result Execution time Memory
929093 2024-02-17T17:13:34 Z haru09 Just Long Neckties (JOI20_ho_t1) C++17
0 / 100
1 ms 2392 KB
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fi first
#define se second
#define task "code"

const int ar=2e5+5;
const ll mod=1e9+7;
int n;
pair<int,int> a[ar];
int b[ar];
int pre[ar];
int suf[ar];
int ans[ar];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    if (fopen(task".inp","r"))
    {
        freopen(task".inp","r",stdin);
        freopen(task".out","w",stdout);
    }
    cin>>n;
    for (int i=1;i<=n+1;i++)
    {
        cin>>a[i].fi;
        a[i].se=i;
    }
    for (int i=1;i<=n;i++) cin>>b[i];
    sort(a+1,a+n+2);
    sort(b+1,b+n+1);
    for (int i=1;i<=n;i++) pre[i]=max({0,pre[i-1],a[i].fi-b[i]});
    for (int i=n;i>=1;i--) suf[i]=max({0,suf[i+1],a[i+1].fi-b[i]});
    for (int i=1;i<=n;i++) ans[a[i].se]=max(pre[i-1],suf[i]);
    for (int i=1;i<=n+1;i++) cout<<ans[i]<<' ';

}

Compilation message

ho_t1.cpp: In function 'int main()':
ho_t1.cpp:22:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |         freopen(task".inp","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
ho_t1.cpp:23:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |         freopen(task".out","w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2392 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2392 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2392 KB Output isn't correct
2 Halted 0 ms 0 KB -