# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
658696 | blue | Foehn Phenomena (JOI17_foehn_phenomena) | C++17 | 277 ms | 7404 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 <iostream>
#include <vector>
using namespace std;
int main()
{
long long N, Q, S, T;
cin >> N >> Q >> S >> T;
long long a, b;
long long D[N+1];
long long w = 0;
cin >> b;
for(long long i = 1; i <= N; i++)
{
a = b;
cin >> b;
D[i] = b-a;
w += -D[i] * (D[i] > 0 ? S:T);
}
long long l, r, u;
vector<long long> res;
for(long long i = 1; i <= Q; i++)
{
cin >> l >> r >> u;
w -= -D[l] * (D[l] > 0 ? S:T);
D[l] += u;
w += -D[l] * (D[l] > 0 ? S:T);
if(r != N)
{
w -= -D[r+1] * (D[r+1] > 0 ? S:T);
D[r+1] -= u;
w += -D[r+1] * (D[r+1] > 0 ? S:T);
}
long long q = 0;
res.push_back(w);
}
for(long long y:res) cout << y << '\n';
return 0;
}
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... |