# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1018255 | vjudge1 | Foehn Phenomena (JOI17_foehn_phenomena) | C++17 | 75 ms | 13148 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define pii pair <int, int>
#define pb push_back
#define pp pop_back
#define int int64_t
#define sc second
#define fr first
using namespace std;
const int T=1e18+7, K=1e9+7;
signed main() {
ios::sync_with_stdio(0);
cin.tie(0);
int n, q, s, t, i, j, l, r, x, ans=0;
cin >> n >> q >> s >> t;
vector <int> v(n+1), d(n+1);
cin >> v[0];
// 1 2
// 0 4 1 8
// -4 2-5
// 0 6 3 8
// -6 0-5
//
// 0 4 3 8
// -4-2-7
// 8 1 1 2
// 0 5 9|3 -2 9 4|6 7
// -5 -9 3 13 2 12 10 9
// 0 5 9|8 3 14 9|6 7
// -5 -9 -7 3 -8 2 8 7
for (i=1; i<=n; i++) {
cin >> v[i];
d[i]=v[i]-v[i-1];
if (d[i]>0) {
ans-=d[i]*s;
}
else {
ans-=d[i]*t;
}
}
while (q--) {
cin >> l >> r >> x;
if (d[l]>0) {
ans+=d[l]*s;
}
else {
ans+=d[l]*t;
}
if (r+1<=n) {
if (d[r+1]>0) {
ans+=d[r+1]*s;
}
else {
ans+=d[r+1]*t;
}
}
d[l]+=x;
if (r+1<=n) {
d[r+1]-=x;
}
if (d[l]>0) {
ans-=d[l]*s;
}
else {
ans-=d[l]*t;
}
if (r+1<=n) {
if (d[r+1]>0) {
ans-=d[r+1]*s;
}
else {
ans-=d[r+1]*t;
}
}
cout << ans << '\n';
}
}
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... |