Submission #936662

# Submission time Handle Problem Language Result Execution time Memory
936662 2024-03-02T13:03:09 Z kitlix Foehn Phenomena (JOI17_foehn_phenomena) C++17
100 / 100
91 ms 8784 KB
#include <bits/stdc++.h>
#define int long long

using namespace std;

signed main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    int n, q, s, t;
    cin >> n >> q >> s >> t;
    vector<int> diff(n);
    int prv = 0;
    cin >> prv;
    int curans = 0;
    auto conv = [&](int x) {
        if (x < 0)
            return -x * t;
        return -x * s;
        };
    for (int i = 0; i < n; ++i) {
        int cur;
        cin >> cur;
        diff[i] = cur - prv;
        curans += conv(diff[i]);
        prv = cur;
    }
    while (q--) {
        int li, ri, xi;
        cin >> li >> ri >> xi;
        curans -= conv(diff[li - 1]);
        diff[li - 1] += xi;
        curans += conv(diff[li - 1]);
        if (ri != n) {
            curans -= conv(diff[ri]);
            diff[ri] -= xi;
            curans += conv(diff[ri]);
        }
        cout << curans << '\n';
    }
}

# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 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 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 544 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 464 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 520 KB Output is correct
15 Correct 1 ms 600 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 72 ms 6372 KB Output is correct
2 Correct 73 ms 6988 KB Output is correct
3 Correct 78 ms 7516 KB Output is correct
4 Correct 68 ms 6732 KB Output is correct
5 Correct 71 ms 7736 KB Output is correct
6 Correct 67 ms 7360 KB Output is correct
7 Correct 64 ms 7316 KB Output is correct
8 Correct 74 ms 7960 KB Output is correct
9 Correct 80 ms 8212 KB Output is correct
10 Correct 87 ms 7272 KB Output is correct
11 Correct 61 ms 7328 KB Output is correct
12 Correct 63 ms 7760 KB Output is correct
13 Correct 63 ms 8276 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 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 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 544 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 464 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 520 KB Output is correct
15 Correct 1 ms 600 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 72 ms 6372 KB Output is correct
23 Correct 73 ms 6988 KB Output is correct
24 Correct 78 ms 7516 KB Output is correct
25 Correct 68 ms 6732 KB Output is correct
26 Correct 71 ms 7736 KB Output is correct
27 Correct 67 ms 7360 KB Output is correct
28 Correct 64 ms 7316 KB Output is correct
29 Correct 74 ms 7960 KB Output is correct
30 Correct 80 ms 8212 KB Output is correct
31 Correct 87 ms 7272 KB Output is correct
32 Correct 61 ms 7328 KB Output is correct
33 Correct 63 ms 7760 KB Output is correct
34 Correct 63 ms 8276 KB Output is correct
35 Correct 77 ms 6652 KB Output is correct
36 Correct 84 ms 8040 KB Output is correct
37 Correct 78 ms 8688 KB Output is correct
38 Correct 76 ms 8640 KB Output is correct
39 Correct 78 ms 8700 KB Output is correct
40 Correct 74 ms 8532 KB Output is correct
41 Correct 91 ms 8380 KB Output is correct
42 Correct 74 ms 8528 KB Output is correct
43 Correct 72 ms 7644 KB Output is correct
44 Correct 75 ms 8276 KB Output is correct
45 Correct 78 ms 8020 KB Output is correct
46 Correct 72 ms 8784 KB Output is correct
47 Correct 83 ms 8016 KB Output is correct
48 Correct 64 ms 8348 KB Output is correct
49 Correct 62 ms 7248 KB Output is correct
50 Correct 60 ms 8016 KB Output is correct
51 Correct 64 ms 8016 KB Output is correct
52 Correct 61 ms 7988 KB Output is correct