제출 #68237

#제출 시각아이디문제언어결과실행 시간메모리
68237WindazzFoehn Phenomena (JOI17_foehn_phenomena)C++14
100 / 100
512 ms7496 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=2e5+123; const int dx[]={0ll,0ll,1,-1}; const int dy[]={1,-1,0ll,0ll}; ll a[N],x[N]; int main(){ ios_base::sync_with_stdio(0ll); cin.tie(0ll); int n,q; ll s,t; cin>>n>>q>>s>>t; ll ans=0ll; cin>>a[0ll]; for(int i=1;i<=n;i++){ cin>>a[i]; x[i]=-a[i]+a[i-1]; ans+=1ll*s*min(x[i],0ll); ans+=1ll*t*max(x[i],0ll); } int l,r,c; while(q--){ cin>>l>>r>>c; r++; if(l<=n){ ans-=s*min(x[l],0ll); ans-=t*max(x[l],0ll); x[l]-=c; ans+=s*min(x[l],0ll); ans+=t*max(x[l],0ll); } if(r<=n){ ans-=s*min(x[r],0ll); ans-=t*max(x[r],0ll); x[r]+=c; ans+=s*min(x[r],0ll); ans+=t*max(x[r],0ll); } cout<<ans<<endl; } return 0ll; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...