Submission #533868

# Submission time Handle Problem Language Result Execution time Memory
533868 2022-03-07T13:39:30 Z someone Snowball (JOI21_ho_t2) C++14
100 / 100
310 ms 26180 KB
#include <bits/stdc++.h>
#define int long long
using namespace std;
 
const int N = 2e5 + 42, INF = 1e18;

set<pair<int, int>> inter;
int n, d, pos[N], dep[N], mini[N], maxi[N];

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    cin >> n >> d;
    pos[0] = -INF;
    pos[n+1] = INF;
    for(int i = 1; i <= n; i++)
        cin >> pos[i];
    for(int i = 1; i <= d; i++) {
        cin >> dep[i];
        dep[i] += dep[i-1];
        mini[i] = min(mini[i-1], dep[i]);
        maxi[i] = max(maxi[i-1], dep[i]);
        inter.insert({maxi[i] - mini[i], i});
    }
    for(int i = 1; i <= n; i++) {
        int ans = 0,
            pre = pos[i] - pos[i-1],
            aft = pos[i+1] - pos[i];
        auto it = inter.lower_bound({pre, 0});
        if(it == inter.end()) {
            ans += -mini[d];
        } else {
            int j = (*it).second;
            if(dep[j-1] < dep[j]) {
                ans += -mini[j];
            } else {
                ans += pre - maxi[j];
            }
        }
        it = inter.lower_bound({aft, 0});
        if(it == inter.end()) {
            ans += maxi[d];
        } else {
            int j = (*it).second;
            if(dep[j-1] > dep[j]) {
                ans += maxi[j];
            } else {
                ans += aft + mini[j];
            }
        }
        cout << ans << '\n';
    }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 460 KB Output is correct
2 Correct 1 ms 456 KB Output is correct
3 Correct 1 ms 460 KB Output is correct
4 Correct 2 ms 588 KB Output is correct
5 Correct 3 ms 456 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 464 KB Output is correct
9 Correct 2 ms 460 KB Output is correct
10 Correct 1 ms 460 KB Output is correct
11 Correct 1 ms 492 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 0 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 2 ms 588 KB Output is correct
16 Correct 2 ms 592 KB Output is correct
17 Correct 1 ms 588 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 2 ms 460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 460 KB Output is correct
2 Correct 1 ms 456 KB Output is correct
3 Correct 1 ms 460 KB Output is correct
4 Correct 2 ms 588 KB Output is correct
5 Correct 3 ms 456 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 464 KB Output is correct
9 Correct 2 ms 460 KB Output is correct
10 Correct 1 ms 460 KB Output is correct
11 Correct 1 ms 492 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 0 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 2 ms 588 KB Output is correct
16 Correct 2 ms 592 KB Output is correct
17 Correct 1 ms 588 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 2 ms 460 KB Output is correct
20 Correct 77 ms 19632 KB Output is correct
21 Correct 82 ms 19412 KB Output is correct
22 Correct 72 ms 19188 KB Output is correct
23 Correct 71 ms 19012 KB Output is correct
24 Correct 93 ms 19452 KB Output is correct
25 Correct 305 ms 24344 KB Output is correct
26 Correct 293 ms 24260 KB Output is correct
27 Correct 301 ms 23896 KB Output is correct
28 Correct 302 ms 24164 KB Output is correct
29 Correct 299 ms 23672 KB Output is correct
30 Correct 233 ms 22980 KB Output is correct
31 Correct 133 ms 22468 KB Output is correct
32 Correct 119 ms 22616 KB Output is correct
33 Correct 18 ms 2740 KB Output is correct
34 Correct 271 ms 24844 KB Output is correct
35 Correct 290 ms 24148 KB Output is correct
36 Correct 310 ms 24368 KB Output is correct
37 Correct 295 ms 24100 KB Output is correct
38 Correct 294 ms 24004 KB Output is correct
39 Correct 228 ms 24196 KB Output is correct
40 Correct 140 ms 24072 KB Output is correct
41 Correct 88 ms 20288 KB Output is correct
42 Correct 136 ms 22520 KB Output is correct
43 Correct 143 ms 25892 KB Output is correct
44 Correct 77 ms 20128 KB Output is correct
45 Correct 151 ms 24056 KB Output is correct
46 Correct 141 ms 26020 KB Output is correct
47 Correct 148 ms 26180 KB Output is correct
48 Correct 141 ms 26052 KB Output is correct