Submission #850933

# Submission time Handle Problem Language Result Execution time Memory
850933 2023-09-17T22:58:42 Z raphaelp Snowball (JOI21_ho_t2) C++14
100 / 100
172 ms 15444 KB
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long N, Q;
    cin >> N >> Q;
    vector<long long> X(N);
    for (long long i = 0; i < N; i++)
    {
        cin >> X[i];
    }
    vector<long long> l(N, -1);
    vector<long long> r(N, -1);
    vector<pair<long long, long long>> dist(N - 1);
    for (long long i = 0; i < N - 1; i++)
    {
        dist[i] = {abs(X[i + 1] - X[i]), i};
    }
    sort(dist.begin(), dist.end());
    long long rm = 0, lm = 0, cur = 0, buff = 0;
    for (long long i = 0; i < Q; i++)
    {
        long long val;
        cin >> val;
        cur += val;
        rm = max(rm, cur);
        lm = min(lm, cur);
        while (buff < N - 1 && rm - lm >= dist[buff].first)
        {
            if (val > 0)
            {
                l[dist[buff].second + 1] = -lm;
                r[dist[buff].second] = dist[buff].first + lm;
            }
            else
            {
                r[dist[buff].second] = rm;
                l[dist[buff].second + 1] = dist[buff].first - rm;
            }
            buff++;
        }
    }
    for (long long i = 0; i < N; i++)
    {
        if (l[i] == -1)
            l[i] = -lm;
        if (r[i] == -1)
            r[i] = rm;
        cout << l[i] + r[i] << '\n';
    }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 2 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 2 ms 604 KB Output is correct
5 Correct 2 ms 344 KB Output is correct
6 Correct 2 ms 344 KB Output is correct
7 Correct 2 ms 344 KB Output is correct
8 Correct 2 ms 348 KB Output is correct
9 Correct 3 ms 600 KB Output is correct
10 Correct 2 ms 348 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 2 ms 344 KB Output is correct
16 Correct 2 ms 348 KB Output is correct
17 Correct 2 ms 344 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 2 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 2 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 2 ms 604 KB Output is correct
5 Correct 2 ms 344 KB Output is correct
6 Correct 2 ms 344 KB Output is correct
7 Correct 2 ms 344 KB Output is correct
8 Correct 2 ms 348 KB Output is correct
9 Correct 3 ms 600 KB Output is correct
10 Correct 2 ms 348 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 2 ms 344 KB Output is correct
16 Correct 2 ms 348 KB Output is correct
17 Correct 2 ms 344 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 2 ms 344 KB Output is correct
20 Correct 61 ms 2384 KB Output is correct
21 Correct 56 ms 2128 KB Output is correct
22 Correct 53 ms 1944 KB Output is correct
23 Correct 49 ms 2008 KB Output is correct
24 Correct 55 ms 2900 KB Output is correct
25 Correct 143 ms 13392 KB Output is correct
26 Correct 138 ms 13392 KB Output is correct
27 Correct 138 ms 13144 KB Output is correct
28 Correct 142 ms 13220 KB Output is correct
29 Correct 141 ms 12624 KB Output is correct
30 Correct 129 ms 12216 KB Output is correct
31 Correct 125 ms 11588 KB Output is correct
32 Correct 115 ms 11700 KB Output is correct
33 Correct 15 ms 1624 KB Output is correct
34 Correct 145 ms 13904 KB Output is correct
35 Correct 137 ms 13136 KB Output is correct
36 Correct 146 ms 13392 KB Output is correct
37 Correct 141 ms 13136 KB Output is correct
38 Correct 142 ms 13012 KB Output is correct
39 Correct 146 ms 13136 KB Output is correct
40 Correct 145 ms 13392 KB Output is correct
41 Correct 91 ms 3152 KB Output is correct
42 Correct 128 ms 11600 KB Output is correct
43 Correct 162 ms 15032 KB Output is correct
44 Correct 71 ms 2832 KB Output is correct
45 Correct 136 ms 13116 KB Output is correct
46 Correct 161 ms 15188 KB Output is correct
47 Correct 172 ms 15444 KB Output is correct
48 Correct 168 ms 15424 KB Output is correct