# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
287582 | fgojko | Foehn Phenomena (JOI17_foehn_phenomena) | C++14 | 553 ms | 11896 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>
//#define FEEDBACK
using namespace std;
typedef long long ll;
int main()
{
ios_base::sync_with_stdio(false);
int n, q;
ll s, t;
cin >> n >> q >> s >> t;
s *= -1;
vector<ll> vec(n);
ll l1, l2;
cin >> l1;
ll temp = 0;
for(int i = 0; i < n; ++i){
cin >> l2;
vec[i] = l1-l2;
if(vec[i] < 0){
temp -= vec[i]*s;
}
else{
temp += vec[i]*t;
}
l1 = l2;
}
int l, k;
ll x, y;
vector<ll> res(q);
bool b1, b2;
for(int i = 0; i < q; ++i){
cin >> l >> k >> x;
--l;
y = vec[l];
vec[l] -= x;
if(y < 0){
temp += y*s;
}
else{
temp -= y*t;
}
if(vec[l] < 0){
temp -= vec[l]*s;
}
else{
temp += vec[l]*t;
}
if(k < n){
y = vec[k];
vec[k] += x;
if(y < 0){
temp += y*s;
}
else{
temp -= y*t;
}
if(vec[k] < 0){
temp -= vec[k]*s;
}
else{
temp += vec[k]*t;
}
}
res[i] = temp;
}
for(int i = 0; i < q; ++i){
cout << res[i] << endl;
}
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... |