Submission #652609

# Submission time Handle Problem Language Result Execution time Memory
652609 2022-10-23T13:51:33 Z jerzyk Snowball (JOI21_ho_t2) C++17
0 / 100
1 ms 340 KB
#include<bits/stdc++.h>

using namespace std;
#define nd second
#define st first
#define pb push_back
typedef long long ll;
typedef long double ld;
const int N = 200 * 1000 + 7;
ll tab[N], pr[N], mi[N], ma[N];
ll ans[N];

int BS(int a, int b, int q)
{
    int p = 0, s, k = q + 1;
    if(a > b) swap(a, b);
    while(p < k)
    {
        s = (p + k) / 2;
        if(-mi[s] + ma[s] >= tab[b] - tab[a])
            k = s;
        else
            p = s + 1;
    }
    return p;
}

void Solve()
{
    int n, q, t;
    cin >> n >> q;
    for(int i = 1; i <= n; ++i)
        cin >> tab[i];
    for(int i = 1; i <= q; ++i)
    {
        cin >> pr[i];
        pr[i] += pr[i - 1];
        ma[i] = max(ma[i - 1], pr[i]);
        mi[i] = min(mi[i - 1], pr[i]);
    }

    ans[1] += abs(mi[q]);
    for(int i = 1; i < n; ++i)
    {
        int k = tab[i + 1], p = tab[i];
        t = BS(i, i + 1, q);
        cout << i << " " << t << "\n";
        if(ma[t] == ma[t - 1])
        {
            ans[i] += ma[t];
            ans[i + 1] += (k - p) - ma[t];
        }else
        {
            ans[i + 1] += (-mi[t]);
            ans[i] += (k - p) - (-mi[t]);
        }
    }
    ans[n] += ma[q];
    for(int i = 1; i <= n; ++i)
        cout << ans[i] << "\n";
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    Solve();

    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -