| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1306957 | ballbreaker | Foehn Phenomena (JOI17_foehn_phenomena) | C++20 | 1094 ms | 1996 KiB |
#include <bits/stdc++.h>
#define int long long
using namespace std;
main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n, q, s, t;
cin >> n >> q >> s >> t;
int a[n + 1];
for (int i = 0; i <= n; i++) {
cin >> a[i];
}
while (q--) {
int l, r, x;
cin >> l >> r >> x;
for (int j = l; j <= r; j++) {
a[j] += x;
}
int ans = 0;
for (int i = 1; i <= n; i++) {
if (a[i - 1] < a[i]) {
ans -= s * (a[i] - a[i - 1]);
} else {
ans += t * (a[i - 1] - a[i]);
}
// cout << ans << ' ';
}
cout << ans << endl;
}
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
