답안 #868605

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
868605 2023-11-01T00:16:31 Z 12345678 Snowball (JOI21_ho_t2) C++17
100 / 100
166 ms 23284 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];
        if (d>h-l)
        {
            ans[i]+=h;
            ans[i+1]-=l;
            continue;
        }
        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';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2904 KB Output is correct
5 Correct 1 ms 2556 KB Output is correct
6 Correct 1 ms 2648 KB Output is correct
7 Correct 1 ms 2652 KB Output is correct
8 Correct 1 ms 2652 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2528 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 0 ms 2396 KB Output is correct
13 Correct 0 ms 2396 KB Output is correct
14 Correct 1 ms 2516 KB Output is correct
15 Correct 1 ms 2652 KB Output is correct
16 Correct 2 ms 2652 KB Output is correct
17 Correct 1 ms 2652 KB Output is correct
18 Correct 1 ms 2392 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2904 KB Output is correct
5 Correct 1 ms 2556 KB Output is correct
6 Correct 1 ms 2648 KB Output is correct
7 Correct 1 ms 2652 KB Output is correct
8 Correct 1 ms 2652 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2528 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 0 ms 2396 KB Output is correct
13 Correct 0 ms 2396 KB Output is correct
14 Correct 1 ms 2516 KB Output is correct
15 Correct 1 ms 2652 KB Output is correct
16 Correct 2 ms 2652 KB Output is correct
17 Correct 1 ms 2652 KB Output is correct
18 Correct 1 ms 2392 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 57 ms 17140 KB Output is correct
21 Correct 51 ms 16760 KB Output is correct
22 Correct 50 ms 16564 KB Output is correct
23 Correct 73 ms 16436 KB Output is correct
24 Correct 57 ms 16720 KB Output is correct
25 Correct 166 ms 21208 KB Output is correct
26 Correct 154 ms 21088 KB Output is correct
27 Correct 145 ms 19728 KB Output is correct
28 Correct 125 ms 18772 KB Output is correct
29 Correct 97 ms 13348 KB Output is correct
30 Correct 58 ms 7556 KB Output is correct
31 Correct 40 ms 6736 KB Output is correct
32 Correct 38 ms 7112 KB Output is correct
33 Correct 10 ms 4184 KB Output is correct
34 Correct 64 ms 9468 KB Output is correct
35 Correct 73 ms 9556 KB Output is correct
36 Correct 138 ms 20376 KB Output is correct
37 Correct 111 ms 17232 KB Output is correct
38 Correct 152 ms 19724 KB Output is correct
39 Correct 127 ms 20048 KB Output is correct
40 Correct 105 ms 19980 KB Output is correct
41 Correct 55 ms 17616 KB Output is correct
42 Correct 37 ms 6988 KB Output is correct
43 Correct 114 ms 22868 KB Output is correct
44 Correct 73 ms 17456 KB Output is correct
45 Correct 88 ms 19844 KB Output is correct
46 Correct 110 ms 22872 KB Output is correct
47 Correct 66 ms 15132 KB Output is correct
48 Correct 104 ms 23284 KB Output is correct