Submission #503529

# Submission time Handle Problem Language Result Execution time Memory
503529 2022-01-08T10:14:27 Z FronPaw JJOOII 2 (JOI20_ho_t2) C++14
0 / 100
0 ms 332 KB
#include <bits/stdc++.h>
#define mod 1000000007
//define int long long
// https://www.youtube.com/watch?v=t5GDacP_2pQ
using namespace std;
ifstream in ("film.in");
ofstream out ("film.out");
int pow (int a, int b)
{
    int rez = 1;
    while (b)
    {
        if (b&1)
            rez = (rez * a) % mod;
        a = (a * a) % mod;
        b>>=1;
    }
    return rez;
}
pair <int, int> a[200002];
int b[200001], n;
int ans[200001];
int st[200001];
int dr[200001];
void solve ()
{
    cin >> n;
    for (int i = 1;i<=n+1;++i)
    {
        cin >> a[i].first;
        a[i].second = i;
    }
    for (int i = 1;i<=n;++i)
        cin >> b[i];
    sort(a + 1, a + n + 2);
    sort(b + 1, b + n + 1);
    b[n+1] = a[n+1].first;
    for (int i = 1;i<=n;++i)
        st[i] = max(st[i-1], max(0, a[i].first - b[i]));
    dr[n+1] = 0;
    for (int i = n;i>=1;--i)
        dr[i] = max(dr[i+1], max(0, a[i+1].first - b[i]));
    for (int i = n + 1;i>=1;--i)
        ans[a[i].second] = max(dr[i], st[i-1]);
    for (int i = 1;i<=n+1;++i)
        cout << ans[i] << ' ';
    cout << '\n';
}
main ()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1;
    //cin >> t;
    while (t--)
        solve();
}

Compilation message

ho_t2.cpp:49:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   49 | main ()
      | ^~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -