제출 #129283

#제출 시각아이디문제언어결과실행 시간메모리
129283DajuncticFoehn Phenomena (JOI17_foehn_phenomena)C++17
100 / 100
565 ms7416 KiB
/*
 _   ________   ___       __ ___   _           _  _
| | / /|  _  \ / _ \     / // _ \ | |         | |(_)
| |/ / | | | |/ /_\ \   / // /_\ \| | __ __ _ | | _
|    \ | | | ||  _  |  / / |  _  || |/ // _` || || |
| |\  \| |/ / | | | | / /  | | | ||   <| (_| || || |
\_| \_/|___/  \_| |_//_/   \_| |_/|_|\_\\__,_||_||_|
*/
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N = 2e5+50;
const int mod = 1e9+7;
#define pb push_back
const int in = 1e9+9;
typedef pair<int,int> ii;
int n, q, s, t;
int d[N], wind = 0, ans[N];
#define fi first
#define se second
signed main(){
	cin >> n >> q >> s >> t;
	int cur = 0;
	for(int i=0;i<=n;i++){
		cin >> d[i];
		d[i] = d[i] - cur;
		cur = d[i] + cur;
	}
	for(int i=1;i<=n;i++){
        if(d[i]>0) wind -= d[i] * s;
        else wind -= d[i] * t;
    }
    for(int i=1;i<=q;i++){
        int  a, b, x;
        cin >> a >> b >> x;
        if(d[a] > 0)  wind += d[a] * s;
        else wind += d[a] * t;
        if(b != n) {
            if(d[b+1]>0) wind += d[b+1] * s;
            else wind += d[b+1] * t;
        }
        d[a] += x;
        d[b+1] -= x;
        if(d[a] > 0)  wind -= d[a] * s;
        else  wind -= d[a] * t;
        if(b!=n) {
            if(d[b+1]>0) wind -= d[b+1] * s;
            else wind -= d[b+1] * t;
        }
        ans[i] = wind;
    }
    for(int i=1;i<=q;i++) cout << ans[i] << "\n";
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...