Submission #940563

# Submission time Handle Problem Language Result Execution time Memory
940563 2024-03-07T10:43:23 Z Hanksburger Snowball (JOI21_ho_t2) C++17
100 / 100
95 ms 17188 KB
#include <bits/stdc++.h>
using namespace std;
vector<pair<long long, pair<long long, long long> > > v;
pair<long long, long long> p[200005];
long long a[200005];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    long long n, m, x, sum=0, mx0=0, mx1=0;
    cin >> n >> m;
    a[0]=-1e18, a[n+1]=1e18;
    for (long long i=1; i<=n; i++)
        cin >> a[i];
    v.push_back({0, {0, 0}});
    for (long long i=1; i<=m; i++)
    {
        cin >> x;
        sum+=x;
        mx0=max(mx0, sum);
        mx1=max(mx1, -sum);
        v.push_back({mx0+mx1, {mx0, mx1}});
    }
    for (long long i=0; i<=n; i++)
    {
        long long ind=lower_bound(v.begin(), v.end(), make_pair(a[i+1]-a[i]+1, make_pair(0LL, 0LL)))-v.begin();
        if (ind==m+1)
            p[i]=v[ind-1].second;
        else if (v[ind-1].second.first==v[ind].second.first)
            p[i]={v[ind].second.first, a[i+1]-a[i]-v[ind].second.first};
        else
            p[i]={a[i+1]-a[i]-v[ind].second.second, v[ind].second.second};
        if (i)
            cout << p[i-1].second+p[i].first << '\n';
    }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 1 ms 516 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 1 ms 600 KB Output is correct
8 Correct 1 ms 604 KB Output is correct
9 Correct 1 ms 604 KB Output is correct
10 Correct 1 ms 604 KB Output is correct
11 Correct 1 ms 600 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 1 ms 604 KB Output is correct
17 Correct 1 ms 604 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 508 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 1 ms 516 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 1 ms 600 KB Output is correct
8 Correct 1 ms 604 KB Output is correct
9 Correct 1 ms 604 KB Output is correct
10 Correct 1 ms 604 KB Output is correct
11 Correct 1 ms 600 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 1 ms 604 KB Output is correct
17 Correct 1 ms 604 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 508 KB Output is correct
20 Correct 23 ms 8388 KB Output is correct
21 Correct 22 ms 8140 KB Output is correct
22 Correct 25 ms 8140 KB Output is correct
23 Correct 29 ms 10144 KB Output is correct
24 Correct 28 ms 9712 KB Output is correct
25 Correct 78 ms 15172 KB Output is correct
26 Correct 79 ms 16052 KB Output is correct
27 Correct 78 ms 15868 KB Output is correct
28 Correct 79 ms 16052 KB Output is correct
29 Correct 94 ms 15544 KB Output is correct
30 Correct 67 ms 14556 KB Output is correct
31 Correct 49 ms 13652 KB Output is correct
32 Correct 63 ms 13504 KB Output is correct
33 Correct 8 ms 3792 KB Output is correct
34 Correct 80 ms 16300 KB Output is correct
35 Correct 76 ms 14820 KB Output is correct
36 Correct 95 ms 16564 KB Output is correct
37 Correct 80 ms 16312 KB Output is correct
38 Correct 78 ms 16156 KB Output is correct
39 Correct 73 ms 15804 KB Output is correct
40 Correct 74 ms 16152 KB Output is correct
41 Correct 24 ms 9912 KB Output is correct
42 Correct 61 ms 13740 KB Output is correct
43 Correct 58 ms 16688 KB Output is correct
44 Correct 31 ms 8648 KB Output is correct
45 Correct 51 ms 14808 KB Output is correct
46 Correct 58 ms 16916 KB Output is correct
47 Correct 60 ms 17072 KB Output is correct
48 Correct 70 ms 17188 KB Output is correct