Submission #441802

# Submission time Handle Problem Language Result Execution time Memory
441802 2021-07-06T08:20:54 Z benedict0724 Snowball (JOI21_ho_t2) C++17
100 / 100
109 ms 15540 KB
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

ll X[200002];
ll P[200002], N[200002];
vector<pair<ll, int>> v;

int main()
{
    ios::sync_with_stdio(false); cin.tie(NULL);
    int n, q; cin >> n >> q;
    for(int i=1;i<=n;i++) cin >> X[i];
    for(int i=1;i<n;i++) v.push_back({X[i+1] - X[i], i});

    ll Neg = 0, Pos = 0, W = 0;
    sort(v.begin(), v.end());
    for(int i=1;i<=n;i++) P[i] = -1;
    for(int i=1;i<=n;i++) N[i] = 1;
    for(int i=1,j=0;i<=q;i++)
    {
        ll A; cin >> A;
        W += A;
        Pos = max(Pos, W);
        Neg = min(Neg, W);

        while(j < n-1 && v[j].first <= Pos - Neg)
        {
            int x = v[j].second;
            if(A > 0)
            {
                N[x+1] = Neg;
                P[x] = v[j].first + Neg;
            }
            else
            {
                P[x] = Pos;
                N[x+1] = Pos - v[j].first;
            }
            j++;
        }
    }

    for(int i=1;i<=n;i++)
    {
        if(P[i] == -1) P[i] = Pos;
        if(N[i] == 1) N[i] = Neg;
    }

    for(int i=1;i<=n;i++)
    {
        cout << P[i] - N[i] << "\n";
    }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 2 ms 460 KB Output is correct
5 Correct 2 ms 460 KB Output is correct
6 Correct 2 ms 460 KB Output is correct
7 Correct 1 ms 460 KB Output is correct
8 Correct 1 ms 460 KB Output is correct
9 Correct 1 ms 460 KB Output is correct
10 Correct 2 ms 460 KB Output is correct
11 Correct 1 ms 460 KB Output is correct
12 Correct 0 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 2 ms 460 KB Output is correct
16 Correct 2 ms 460 KB Output is correct
17 Correct 2 ms 460 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 2 ms 460 KB Output is correct
5 Correct 2 ms 460 KB Output is correct
6 Correct 2 ms 460 KB Output is correct
7 Correct 1 ms 460 KB Output is correct
8 Correct 1 ms 460 KB Output is correct
9 Correct 1 ms 460 KB Output is correct
10 Correct 2 ms 460 KB Output is correct
11 Correct 1 ms 460 KB Output is correct
12 Correct 0 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 2 ms 460 KB Output is correct
16 Correct 2 ms 460 KB Output is correct
17 Correct 2 ms 460 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 460 KB Output is correct
20 Correct 31 ms 2368 KB Output is correct
21 Correct 30 ms 2240 KB Output is correct
22 Correct 30 ms 2000 KB Output is correct
23 Correct 28 ms 1960 KB Output is correct
24 Correct 33 ms 3036 KB Output is correct
25 Correct 104 ms 13528 KB Output is correct
26 Correct 106 ms 13492 KB Output is correct
27 Correct 102 ms 13232 KB Output is correct
28 Correct 104 ms 13280 KB Output is correct
29 Correct 100 ms 12752 KB Output is correct
30 Correct 98 ms 12236 KB Output is correct
31 Correct 98 ms 11572 KB Output is correct
32 Correct 78 ms 11736 KB Output is correct
33 Correct 11 ms 1744 KB Output is correct
34 Correct 102 ms 13844 KB Output is correct
35 Correct 106 ms 13396 KB Output is correct
36 Correct 109 ms 13580 KB Output is correct
37 Correct 107 ms 13340 KB Output is correct
38 Correct 105 ms 13184 KB Output is correct
39 Correct 106 ms 13428 KB Output is correct
40 Correct 104 ms 13268 KB Output is correct
41 Correct 37 ms 3012 KB Output is correct
42 Correct 88 ms 11796 KB Output is correct
43 Correct 101 ms 15064 KB Output is correct
44 Correct 36 ms 2884 KB Output is correct
45 Correct 101 ms 13232 KB Output is correct
46 Correct 106 ms 15128 KB Output is correct
47 Correct 103 ms 15408 KB Output is correct
48 Correct 107 ms 15540 KB Output is correct