Submission #933729

# Submission time Handle Problem Language Result Execution time Memory
933729 2024-02-26T08:04:09 Z Irate Foehn Phenomena (JOI17_foehn_phenomena) C++14
0 / 100
80 ms 9512 KB
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, q, s, t;
    cin >> n >> q >> s >> t;
    s = -s;
    vector<int>v(n + 1);
    for(int i = 0;i <= n;++i){
        cin >> v[i];
    }
    vector<int>diff(n + 5);
    int temper = 0;
    for(int i = 1;i <= n;++i){
        diff[i] = v[i] - v[i - 1];
        if(diff[i] < 0){
            temper += (long long)t * -diff[i];
        }
        else{
            temper += (long long)s * diff[i];
        }
    }
    while(q--){
        int l, r, x;
        cin >> l >> r >> x;
        if(diff[l] < 0){
            temper -= (long long)t * -diff[l];
        }
        else{
            temper -= (long long)s * diff[l];
        }
        if(diff[r + 1] < 0){
            temper -= (long long)t * -diff[r + 1];
        }
        else{
            temper -= (long long)s * diff[r + 1];
        }
        diff[l] += x;
        if(r + 1 <= n)diff[r + 1] -= x;
        if(diff[l] < 0){
            temper += (long long)t * -diff[l];
        }
        else{
            temper += (long long)s * diff[l];
        }
        if(diff[r + 1] < 0){
            temper += (long long)t * -diff[r + 1];
        }
        else{
            temper += (long long)s * diff[r + 1];
        }
        cout << temper << '\n';
    }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 80 ms 8780 KB Output is correct
2 Correct 77 ms 9512 KB Output is correct
3 Incorrect 79 ms 9256 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -