Submission #1160010

#TimeUsernameProblemLanguageResultExecution timeMemory
1160010hainam2k9Just Long Neckties (JOI20_ho_t1)C++20
100 / 100
60 ms6984 KiB
#include <bits/stdc++.h>
#define tt cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(0)
#define fo freopen((NAME+".INP").c_str(), "r", stdin), freopen((NAME+".OUT").c_str(), "w", stdout)
#define ll long long
#define ull unsigned long long
#define i128 __int128
#define db long double
#define sz(a) ((int)(a).size())
#define pb emplace_back
#define pf emplace_front
#define pob pop_back
#define pof pop_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define ins emplace
#define mp make_pair
using namespace std;
const int MOD = 1e9+7, MAXN = 2e5+5;
const string NAME = "";
int n,b[MAXN],pre[MAXN],suf[MAXN],rs[MAXN];
pair<int,int> a[MAXN];
int main()
{
    tt;
    if(fopen((NAME + ".INP").c_str(), "r")) fo;
    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(pre[i-1],a[i].fi-b[i]);
    for(int i = n+1; i>1; --i)
        suf[i]=max(suf[i+1],a[i].fi-b[i-1]);
    for(int i = 1; i<=n+1; ++i)
        rs[a[i].se]=max(pre[i-1],suf[i+1]);
    for(int i = 1; i<=n+1; ++i)
        cout << rs[i] << " ";
}

Compilation message (stderr)

ho_t1.cpp: In function 'int main()':
ho_t1.cpp:3:19: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    3 | #define fo freopen((NAME+".INP").c_str(), "r", stdin), freopen((NAME+".OUT").c_str(), "w", stdout)
      |            ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ho_t1.cpp:27:45: note: in expansion of macro 'fo'
   27 |     if(fopen((NAME + ".INP").c_str(), "r")) fo;
      |                                             ^~
ho_t1.cpp:3:63: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    3 | #define fo freopen((NAME+".INP").c_str(), "r", stdin), freopen((NAME+".OUT").c_str(), "w", stdout)
      |                                                        ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ho_t1.cpp:27:45: note: in expansion of macro 'fo'
   27 |     if(fopen((NAME + ".INP").c_str(), "r")) fo;
      |                                             ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...