제출 #1028106

#제출 시각아이디문제언어결과실행 시간메모리
1028106vjudge1Foehn Phenomena (JOI17_foehn_phenomena)C++17
100 / 100
82 ms13076 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define ld long double #define pii pair<int, int> #define pll pair<ll, ll> #define pld pair<ld, ld> #define pb push_back #define fi first #define se second #define debug(x) cout << #x << " => " << x << endl #define all(x) x.begin(),x.end() int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); ll n,q,s,t;cin>>n>>q>>s>>t; ll a[n+1],d[n+2]; d[n+1]=0; for(int i=0;i<=n;i++) cin>>a[i]; for(int i=1;i<=n;i++) d[i]=(a[i-1]-a[i]); ll x=0,y=0; for(int i=1;i<=n;i++) { if(d[i]<0) x+=d[i]; else y+=d[i]; } while(q--) { int l,r,v;cin>>l>>r>>v; if(d[l]<0) x-=d[l]; else y-=d[l]; if(d[r+1]<0) x-=d[r+1]; else y-=d[r+1]; d[l]-=v; d[r+1]+=v; d[n+1]=0; if(d[l]<0) x+=d[l]; else y+=d[l]; if(d[r+1]<0) x+=d[r+1]; else y+=d[r+1]; // for(int i=1;i<=n;i++) cout<<d[i]<<' ';cout<<'\n'; cout<<s*x+t*y<<'\n'; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...