제출 #880371

#제출 시각아이디문제언어결과실행 시간메모리
880371JakobZorzFoehn Phenomena (JOI17_foehn_phenomena)C++14
100 / 100
92 ms12436 KiB
#include<iostream> #include<vector> #include<queue> #include<stack> #include<algorithm> #include<limits.h> #include<math.h> #include<map> #include<set> #include<unordered_map> #include<unordered_set> #include<iomanip> #include<cstring> typedef long long ll; typedef unsigned long long ull; typedef long double ld; using namespace std; //const int MOD=1e9+7; //typedef pair<ll,ll>Point; //typedef pair<ll,ll>Line; //#define x first //#define y second void solve(){ int n,q,s,t; cin>>n>>q>>s>>t; vector<int>arr(n+1); for(int&i:arr) cin>>i; vector<ll>diff(n); ll res=0; for(int i=0;i<n;i++){ diff[i]=arr[i+1]-arr[i]; if(diff[i]>0){ res-=diff[i]*s; }else{ res-=diff[i]*t; } } while(q--){ int l,r,x; cin>>l>>r>>x; l--; //if(l!=-1){ if(diff[l]>0){ res+=diff[l]*s; }else{ res+=diff[l]*t; } diff[l]+=x; if(diff[l]>0){ res-=diff[l]*s; }else{ res-=diff[l]*t; } //} if(r!=n){ if(diff[r]>0){ res+=diff[r]*s; }else{ res+=diff[r]*t; } diff[r]-=x; if(diff[r]>0){ res-=diff[r]*s; }else{ res-=diff[r]*t; } } cout<<res<<"\n"; } } int main(){ ios::sync_with_stdio(false);cout.tie(NULL);cin.tie(NULL); //freopen("bank.in","r",stdin);freopen("bank.out","w",stdout); int t=1;//cin>>t; while(t--)solve(); return 0; } /* 3 5 1 2 0 4 1 8 1 2 2 1 1 -2 2 3 5 1 2 -1 1 3 5 */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...