Submission #886771

#TimeUsernameProblemLanguageResultExecution timeMemory
886771Maite_MoraleFoehn Phenomena (JOI17_foehn_phenomena)C++14
100 / 100
99 ms15828 KiB
#include<bits/stdc++.h> #define F first #define S second #define MAX 500005 #define oo 1e18 #define mod 1000000007 #define fast_in ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);cout.setf(ios::fixed);cout.precision(0); using namespace std; typedef long long ll; #define pll pair<ll , ll> #define vll vector<ll> #define vvll vector<vll> #define vpll vector<pll> ll t,n,a[MAX],s,q,k,p,f; int main(){ fast_in cin>>n>>q>>s>>t;vpll v;ll r=0; for(int i=0;i<=n;i++){ cin>>a[i]; if(i!=0){ v.push_back({a[i-1],a[i]}); if(a[i]-a[i-1]>0)r+=(a[i]-a[i-1])*-s; else r+=(a[i]-a[i-1])*-t; } } for(int i=0;i<q;i++){ cin>>p>>f>>k; if(p>0){ if(v[p-1].S-v[p-1].F>0)r-=(v[p-1].S-v[p-1].F)*-s; else r-=(v[p-1].S-v[p-1].F)*-t; v[p-1].S+=k; if(v[p-1].S-v[p-1].F>0)r+=(v[p-1].S-v[p-1].F)*-s; else r+=(v[p-1].S-v[p-1].F)*-t; } if(f<n){ if(v[f].S-v[f].F>0)r-=(v[f].S-v[f].F)*-s; else r-=(v[f].S-v[f].F)*-t; v[f].F+=k; if(v[f].S-v[f].F>0)r+=(v[f].S-v[f].F)*-s; else r+=(v[f].S-v[f].F)*-t; } cout<<r<<"\n"; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...