제출 #751100

#제출 시각아이디문제언어결과실행 시간메모리
751100vjudge1Foehn Phenomena (JOI17_foehn_phenomena)C++17
30 / 100
1059 ms25248 KiB
#include<bits/stdc++.h>
#define ll long long
using namespace std;

map<ll, ll> a, m, g;
ll n, q, s, t, l, r, x;

int main(){
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n >> q >> s >> t;
	s *= -1; t *= -1;
	a[0] = 0;
	for(int i=0; i<=n; i++){
		cin >> a[i];
		ll tmp = a[i] - a[i-1];
		m[i] = tmp;
	}
	for(int i=1; i<=q; i++){
		cin >> l >> r >> x;
		m[l] += x;
		m[r+1] -= x;
		//ubah ketinggian dari l sampai r sebanyak x
		//untuk mengetahui suhu di rumah pak bondol, yang diperdulikan adalah
		//perubahan dari l-1 ke l dan r ke r+1, perubahan dari l hingga r tetap sama.
		ll ans = 0;
		for(int j=1; j<=n; j++){
			if(m[j] < 0){
				ans += m[j] * t;
			}
			else{
				ans += m[j] * s;
			}
		}
		cout << ans << '\n';
	}
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...