Submission #303555

#TimeUsernameProblemLanguageResultExecution timeMemory
303555Bill_00Foehn Phenomena (JOI17_foehn_phenomena)C++14
30 / 100
1030 ms12360 KiB
#include <bits/stdc++.h> #define ll long long using namespace std; ll a[200001],dp[200001]; int main(){ ll n,q,s,t,ih=0,baga=0; cin >> n >> q >> s >> t; cin >> a[0]; for(int i=1;i<=n;i++){ cin >> a[i]; if(a[i]>a[i-1]){ ih+=(a[i]-a[i-1]); } else baga+=(a[i-1]-a[i]); dp[i]=a[i]-a[i-1]; } for(int i=1;i<=q;i++){ //cout << ih << ' ' << baga << endl; ll l,r,x; cin >> l >> r >> x; ll p=dp[l]; ll q=dp[l]+x; if(p>0 && q>0){ ih+=x; } if(p>0 && q<=0){ ih-=p; baga+=(abs(q)); } if(p<=0 && q>0){ ih+=q; baga-=(abs(p)); } if(p<=0 && q<=0){ baga-=x; } dp[l]=q; if(r!=n){ ll p=dp[r+1]; ll q=dp[r+1]-x; if(p>0 && q>0){ ih-=x; } if(p>0 && q<=0){ ih-=p; baga+=(abs(q)); } if(p<=0 && q>0){ ih+=q; baga-=(abs(p)); } if(p<=0 && q<=0){ baga+=x; } dp[r+1]=q; } cout << -ih*s+baga*t << endl; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...