제출 #259052

#제출 시각아이디문제언어결과실행 시간메모리
259052FidiskFoehn Phenomena (JOI17_foehn_phenomena)C++14
100 / 100
149 ms13296 KiB
#include <bits/stdc++.h> using namespace std; #define oo 1e9 #define fi first #define se second #define sp(iiii) setprecision(iiii) #define IO ios_base::sync_with_stdio(false); cin.tie(0) #define ms(aaaa,xxxx) memset(aaaa,xxxx,sizeof(aaaa)) #define cntbit(xxxx) __builtin_popcount(xxxx) #define getbit(xxxx,aaaa) ((xxxx>>(aaaa-1))&1) #define _cos(xxxx) cos(xxxx*acos(-1)/180) #define _sin(xxxx) sin(xxxx*acos(-1)/180) #define _tan(xxxx) tan(xxxx*acos(-1)/180) #define PE cout<<fixed typedef long double ld; typedef long long ll; typedef unsigned long long ull; typedef pair<int,int> pii; typedef pair<pair<int,int>,int> piii; typedef pair<long long,long long> pll; typedef pair<pair<long long,long long>,long long> plll; const ld pi=acos(-1); ll n,q,s,t,i,a[500009],b[500009],res,l,r,x,tmp1,tmp2; int main(){ IO; cin>>n>>q>>s>>t; for (i=0;i<=n;i++) { cin>>a[i]; } for (i=1;i<=n;i++) { b[i]=a[i]-a[i-1]; } for (i=1;i<=n;i++) { res+=(b[i]>0)?(-b[i]*s):(-b[i]*t); } //cout<<res<<'\n'; for (i=1;i<=q;i++) { cin>>l>>r>>x; tmp1=b[l]+x; tmp2=b[r+1]-x; res+=(b[l]>0)?(b[l]*s):(b[l]*t); res+=(tmp1>0)?(-tmp1*s):(-tmp1*t); if (r!=n) { res+=(b[r+1]>0)?(b[r+1]*s):(b[r+1]*t); res+=(tmp2>0)?(-tmp2*s):(-tmp2*t); } b[l]=tmp1; b[r+1]=tmp2; cout<<res<<'\n'; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...