제출 #68234

#제출 시각아이디문제언어결과실행 시간메모리
68234WindazzFoehn Phenomena (JOI17_foehn_phenomena)C++14
30 / 100
18 ms3360 KiB
#include <iostream> #include <fstream> #include <cstring> #include <sstream> #include <algorithm> #include <cmath> #include <iomanip> #include <vector> #include <stack> #include <queue> #include <deque> #include <map> #include <set> #include <iterator> #include <ext/pb_ds/assoc_container.hpp> #define x first #define y second #define mp make_pair #define up_b upper_bound #define low_b lower_bound #define sz(x) (int)x.size() #define bit __builtin_popcount #define all(x) x.begin(),x.end() using namespace std; using namespace __gnu_pbds; typedef long long ll; typedef long double ld; typedef pair<ll,ll> pll; typedef pair<int,int> pii; typedef pair<int,ll> pil; typedef pair<ll,int> pli; typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set; const ll INF=1e18+123; const ld EPS=1e-9; const int inf=1e9+123; const int MOD=1e9+7; const int N=1e5+123; const int dx[]={0,0,1,-1}; const int dy[]={1,-1,0,0}; int a[N],x[N]; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); int n,q; ll s,t; cin>>n>>q>>s>>t; ll ans=0; cin>>a[0]; for(int i=1;i<=n;i++){ cin>>a[i]; x[i]=-a[i]+a[i-1]; ans+=1ll*s*min(x[i],0); ans+=1ll*t*max(x[i],0); } int l,r,c; while(q--){ cin>>l>>r>>c; r++; if(l<=n){ ans-=s*min(x[l],0); ans-=t*max(x[l],0); x[l]-=c; ans+=s*min(x[l],0); ans+=t*max(x[l],0); } if(r<=n){ ans-=s*min(x[r],0); ans-=t*max(x[r],0); x[r]+=c; ans+=s*min(x[r],0); ans+=t*max(x[r],0); } cout<<ans<<endl; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...