# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
364992 | 2021-02-10T17:15:23 Z | Mamnoon_Siam | Foehn Phenomena (JOI17_foehn_phenomena) | C++17 | 154 ms | 13164 KB |
#include <bits/stdc++.h> using namespace std; /* sorry, this is the bare minimum :'( */ using ll = long long; using ii = pair<int, int>; using vi = vector<int>; #define all(v) begin(v), end(v) #define sz(v) (int)(v).size() #define fi first #define se second const int N = 2e5 + 5; int n, q; ll S, T; ll a[N], d[N]; int main(int argc, char const *argv[]) { #ifdef LOCAL freopen("in", "r", stdin); #endif scanf("%d %d %lld %lld", &n, &q, &S, &T); ll ans = 0; function<void(int,int)> work = [&ans](int i, int x) { if(d[i] >= 0) ans -= S * d[i]; else ans -= T * d[i]; d[i] += x; if(d[i] >= 0) ans += S * d[i]; else ans += T * d[i]; }; for(int i = 0; i <= n; ++i) { scanf("%lld", &a[i]); if(i) { d[i] = a[i] - a[i-1]; if(d[i] >= 0) { ans += S * d[i]; } else { ans += T * d[i]; } } } while(q--) { int l, r, x; scanf("%d %d %d", &l, &r, &x); // debug(l, r, x); work(l, x); if(r < n) work(r+1, -x); printf("%lld\n", -ans); } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 492 KB | Output is correct |
2 | Correct | 2 ms | 492 KB | Output is correct |
3 | Correct | 2 ms | 492 KB | Output is correct |
4 | Correct | 2 ms | 492 KB | Output is correct |
5 | Correct | 2 ms | 492 KB | Output is correct |
6 | Correct | 3 ms | 492 KB | Output is correct |
7 | Correct | 2 ms | 492 KB | Output is correct |
8 | Correct | 2 ms | 492 KB | Output is correct |
9 | Correct | 2 ms | 512 KB | Output is correct |
10 | Correct | 2 ms | 492 KB | Output is correct |
11 | Correct | 2 ms | 492 KB | Output is correct |
12 | Correct | 2 ms | 492 KB | Output is correct |
13 | Correct | 2 ms | 492 KB | Output is correct |
14 | Correct | 2 ms | 492 KB | Output is correct |
15 | Correct | 2 ms | 492 KB | Output is correct |
16 | Correct | 2 ms | 492 KB | Output is correct |
17 | Correct | 2 ms | 492 KB | Output is correct |
18 | Correct | 2 ms | 492 KB | Output is correct |
19 | Correct | 1 ms | 364 KB | Output is correct |
20 | Correct | 1 ms | 384 KB | Output is correct |
21 | Correct | 1 ms | 364 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 130 ms | 10348 KB | Output is correct |
2 | Correct | 151 ms | 10988 KB | Output is correct |
3 | Correct | 132 ms | 11512 KB | Output is correct |
4 | Correct | 130 ms | 10860 KB | Output is correct |
5 | Correct | 140 ms | 12140 KB | Output is correct |
6 | Correct | 115 ms | 11116 KB | Output is correct |
7 | Correct | 118 ms | 10988 KB | Output is correct |
8 | Correct | 136 ms | 12012 KB | Output is correct |
9 | Correct | 139 ms | 12212 KB | Output is correct |
10 | Correct | 132 ms | 10988 KB | Output is correct |
11 | Correct | 113 ms | 10988 KB | Output is correct |
12 | Correct | 119 ms | 11756 KB | Output is correct |
13 | Correct | 113 ms | 11884 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 492 KB | Output is correct |
2 | Correct | 2 ms | 492 KB | Output is correct |
3 | Correct | 2 ms | 492 KB | Output is correct |
4 | Correct | 2 ms | 492 KB | Output is correct |
5 | Correct | 2 ms | 492 KB | Output is correct |
6 | Correct | 3 ms | 492 KB | Output is correct |
7 | Correct | 2 ms | 492 KB | Output is correct |
8 | Correct | 2 ms | 492 KB | Output is correct |
9 | Correct | 2 ms | 512 KB | Output is correct |
10 | Correct | 2 ms | 492 KB | Output is correct |
11 | Correct | 2 ms | 492 KB | Output is correct |
12 | Correct | 2 ms | 492 KB | Output is correct |
13 | Correct | 2 ms | 492 KB | Output is correct |
14 | Correct | 2 ms | 492 KB | Output is correct |
15 | Correct | 2 ms | 492 KB | Output is correct |
16 | Correct | 2 ms | 492 KB | Output is correct |
17 | Correct | 2 ms | 492 KB | Output is correct |
18 | Correct | 2 ms | 492 KB | Output is correct |
19 | Correct | 1 ms | 364 KB | Output is correct |
20 | Correct | 1 ms | 384 KB | Output is correct |
21 | Correct | 1 ms | 364 KB | Output is correct |
22 | Correct | 130 ms | 10348 KB | Output is correct |
23 | Correct | 151 ms | 10988 KB | Output is correct |
24 | Correct | 132 ms | 11512 KB | Output is correct |
25 | Correct | 130 ms | 10860 KB | Output is correct |
26 | Correct | 140 ms | 12140 KB | Output is correct |
27 | Correct | 115 ms | 11116 KB | Output is correct |
28 | Correct | 118 ms | 10988 KB | Output is correct |
29 | Correct | 136 ms | 12012 KB | Output is correct |
30 | Correct | 139 ms | 12212 KB | Output is correct |
31 | Correct | 132 ms | 10988 KB | Output is correct |
32 | Correct | 113 ms | 10988 KB | Output is correct |
33 | Correct | 119 ms | 11756 KB | Output is correct |
34 | Correct | 113 ms | 11884 KB | Output is correct |
35 | Correct | 132 ms | 10404 KB | Output is correct |
36 | Correct | 133 ms | 11884 KB | Output is correct |
37 | Correct | 138 ms | 12652 KB | Output is correct |
38 | Correct | 136 ms | 12524 KB | Output is correct |
39 | Correct | 137 ms | 12524 KB | Output is correct |
40 | Correct | 136 ms | 12524 KB | Output is correct |
41 | Correct | 137 ms | 12524 KB | Output is correct |
42 | Correct | 154 ms | 12428 KB | Output is correct |
43 | Correct | 136 ms | 11628 KB | Output is correct |
44 | Correct | 133 ms | 12140 KB | Output is correct |
45 | Correct | 135 ms | 12140 KB | Output is correct |
46 | Correct | 134 ms | 13164 KB | Output is correct |
47 | Correct | 119 ms | 11884 KB | Output is correct |
48 | Correct | 119 ms | 11756 KB | Output is correct |
49 | Correct | 130 ms | 10732 KB | Output is correct |
50 | Correct | 115 ms | 11500 KB | Output is correct |
51 | Correct | 116 ms | 11920 KB | Output is correct |
52 | Correct | 133 ms | 11756 KB | Output is correct |