# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
979893 | pera | Foehn Phenomena (JOI17_foehn_phenomena) | C++17 | 444 ms | 13176 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 int long long
using namespace std;
const int N = 2e5 + 1;
main(){
int n , q , S , T , sum = 0;
cin >> n >> q >> S >> T;
vector<int> A(n + 1) , d(n + 1);
auto value = [&](int x){
return -d[x] * (d[x] > 0 ? S : T);
};
for(int i = 0;i <= n;i ++){
cin >> A[i];
if(i > 0){
d[i] = A[i] - A[i - 1];
sum += value(i);
}
}
while(q--){
int l , r , x;
cin >> l >> r >> x;
sum -= value(l);
d[l] += x;
sum += value(l);
if(r < n){
sum -= value(r + 1);
d[r + 1] -= x;
sum += value(r + 1);
}
cout << sum << 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... |