답안 #404767

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
404767 2021-05-15T00:50:32 Z ScarletS Snowball (JOI21_ho_t2) C++17
100 / 100
154 ms 16964 KB
#include <bits/stdc++.h>
#define int long long
#define sz(x) (int)(x).size()
using namespace std;

int ans[200000];

signed main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n,m,x=0,y=0,z=0,k;
    cin>>n>>m;
    int a[n];
    vector<array<int,2>> v(n-1),w(n-1);
    for (int i=0;i<n;++i)
        cin>>a[i];
    for (int i=0;i+1<n;++i)
        v[i]=w[i]={a[i+1]-a[i],i};
    sort(v.rbegin(), v.rend());
    sort(w.rbegin(), w.rend());
    while (m--)
    {
        cin>>k;
        z+=k;
        if (k<0)
        {
            while (!v.empty()&&v.back()[0]<=y-z)
            {
                ans[v.back()[1]+1]+=max(v.back()[0]-y,-x);
                //cout<<v.back()[1]+1<<" "<<v.back()[0]-y<<"\n";
                v.pop_back();
            }
        }
        else
        {
            while (!w.empty()&&w.back()[0]<=z-x)
            {
                ans[w.back()[1]]+=max(w.back()[0]+x,y);
                //cout<<w.back()[1]<<" "<<w.back()[0]+x<<"\n";
                w.pop_back();
            }
        }
        x=min(x,z);
        y=max(y,z);
        //cout<<"updated"<<"\n";
    }
    for (auto i : v)
        ans[i[1]+1]-=x;
    for (auto i : w)
        ans[i[1]]+=y;
    ans[0]+=-x;
    ans[n-1]+=y;
    for (int i=0;i<n;++i)
        cout<<ans[i]<<"\n";
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 336 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 2 ms 460 KB Output is correct
8 Correct 2 ms 436 KB Output is correct
9 Correct 3 ms 332 KB Output is correct
10 Correct 2 ms 332 KB Output is correct
11 Correct 2 ms 332 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 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 3 ms 460 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 2 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 336 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 2 ms 460 KB Output is correct
8 Correct 2 ms 436 KB Output is correct
9 Correct 3 ms 332 KB Output is correct
10 Correct 2 ms 332 KB Output is correct
11 Correct 2 ms 332 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 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 3 ms 460 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 2 ms 332 KB Output is correct
20 Correct 34 ms 2348 KB Output is correct
21 Correct 31 ms 2216 KB Output is correct
22 Correct 36 ms 1988 KB Output is correct
23 Correct 28 ms 1988 KB Output is correct
24 Correct 35 ms 3012 KB Output is correct
25 Correct 130 ms 15052 KB Output is correct
26 Correct 144 ms 14900 KB Output is correct
27 Correct 127 ms 14536 KB Output is correct
28 Correct 150 ms 14664 KB Output is correct
29 Correct 131 ms 14276 KB Output is correct
30 Correct 130 ms 13628 KB Output is correct
31 Correct 128 ms 12992 KB Output is correct
32 Correct 94 ms 13252 KB Output is correct
33 Correct 13 ms 1800 KB Output is correct
34 Correct 138 ms 15316 KB Output is correct
35 Correct 128 ms 14672 KB Output is correct
36 Correct 154 ms 14916 KB Output is correct
37 Correct 127 ms 14660 KB Output is correct
38 Correct 145 ms 14668 KB Output is correct
39 Correct 142 ms 14768 KB Output is correct
40 Correct 139 ms 14784 KB Output is correct
41 Correct 43 ms 2976 KB Output is correct
42 Correct 117 ms 13128 KB Output is correct
43 Correct 110 ms 16456 KB Output is correct
44 Correct 34 ms 2848 KB Output is correct
45 Correct 123 ms 14660 KB Output is correct
46 Correct 119 ms 16576 KB Output is correct
47 Correct 145 ms 16860 KB Output is correct
48 Correct 147 ms 16964 KB Output is correct