Submission #941510

#TimeUsernameProblemLanguageResultExecution timeMemory
941510vjudge1Foehn Phenomena (JOI17_foehn_phenomena)C++17
10 / 100
79 ms5712 KiB
#include <bits/stdc++.h> using namespace std; using lint=long long; const int INF=0x3f3f3f3f; const lint LINF=0x3f3f3f3f3f3f3f3f; namespace Type{ using pair_int=std::pair<int,int>; using pair_lint=std::pair<lint,lint>; using pair_real=std::pair<double,double>; using vector_int=vector<int>; using vector_lint=vector<lint>; using vector2d_int=vector<vector<int>>; using vector2d_lint=vector<vector<lint>>; } //#define FILE_IO #define SINGLE_TEST //#define MULTI_TEST void solve(){ int n,q; lint s,t; cin>>n>>q>>s>>t; lint last=0,ans=0; auto calc=[&](lint val)->lint{ if(val>=0) return -t*val; return -val*s; }; Type::vector_lint diff(n+10); for(int i=0;i<=n;i++){ lint temp; cin>>temp; diff[i]=temp-last; last=temp; ans+=calc(diff[i]); } for(int i=1;i<=q;i++){ lint left,right,k; cin>>left>>right>>k; ans-=calc(diff[left]); diff[left]+=k; ans+=calc(diff[left]); if(right<n){ ans-=calc(diff[right+1]); diff[right+1]-=k; ans+=calc(diff[right+1]); } cout<<ans<<"\n"; } } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); #ifdef FILE_IO freopen("../text.in","r",stdin); #endif int T; #ifdef SINGLE_TEST T=1; #endif #ifdef MULTI_TEST cin>>T; #endif while(T--) solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...