Submission #868604

# Submission time Handle Problem Language Result Execution time Memory
868604 2023-11-01T00:13:37 Z 12345678 Snowball (JOI21_ho_t2) C++17
0 / 100
1 ms 2652 KB
#include <bits/stdc++.h>

using namespace std;

#define ll long long

const int nx=2e5+5;
ll n, q, a[nx], h, l, vl, w, ans[nx];
set<tuple<ll, ll, ll>> s;

int main()
{
    cin.tie(NULL)->sync_with_stdio(false);
    cin>>n>>q;
    for (int i=1; i<=n; i++) cin>>a[i];
    while (q--)
    {
        cin>>w;
        if (vl+w>h) h=vl+w, s.insert(make_tuple(h-l, h, 1));
        if (vl+w<l) l=vl+w, s.insert(make_tuple(h-l, h, 0));
        vl+=w;
    }
    for (int i=1; i<n; i++)
    {
        ll d=a[i+1]-a[i];
        auto [val, ch, t]=*s.lower_bound(make_tuple(d, LLONG_MIN, LLONG_MIN));
        if (t) ans[i+1]+=val-ch, ans[i]+=d-(val-ch);
        else ans[i]+=ch, ans[i+1]+=d-ch;
    }
    ans[1]+=-l;
    ans[n]+=h;
    for (int i=1; i<=n; i++) cout<<ans[i]<<'\n';
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2652 KB Output is correct
2 Correct 1 ms 2528 KB Output is correct
3 Correct 1 ms 2652 KB Output is correct
4 Incorrect 1 ms 2560 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2652 KB Output is correct
2 Correct 1 ms 2528 KB Output is correct
3 Correct 1 ms 2652 KB Output is correct
4 Incorrect 1 ms 2560 KB Output isn't correct
5 Halted 0 ms 0 KB -