# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1279872 | hanguyendanghuy | Foehn Phenomena (JOI17_foehn_phenomena) | C++20 | 1 ms | 568 KiB |
#include <bits/stdc++.h>
using namespace std;
#define yes cout<<"YES"<<'\n'
#define no cout<<"NO"<<'\n'
#define si size()
#define fi first
#define se second
#define ll long long
#define sr sort
#define pb push_back
const ll MAXN=1e3+5,INF=1e9,MOD=1e9+7;
ll n,m,i,j,k,p,dem,t,sum,ans,a[MAXN],b[MAXN];
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);cout.tie(0);
freopen("test.INP","r",stdin);
freopen("test.OUT","w",stdout);
ll S,T,ans=0;
cin>>n>>m>>S>>T;
for(i=0;i<=n;i++) cin>>a[i];
for(i=1;i<=n;i++){
b[i]=a[i-1]-a[i];
if(b[i]<0) ans+=b[i]*S;
else ans+=b[i]*T;
}
for(i=1;i<=m;i++){
ll l,r,k;
cin>>l>>r>>k;
if(b[l]<0) ans-=b[l]*S;
else ans-=b[l]*T;
b[l]-=k;
if(b[l]<0) ans+=b[l]*S;
else ans+=b[l]*T;
if(r+1<=n){
if(b[r+1]<0) ans-=b[r+1]*S;
else ans-=b[r+1]*T;
b[r+1]+=k;
if(b[r+1]<0) ans+=b[r+1]*S;
else ans+=b[r+1]*T;
}
cout<<ans<<'\n';
}
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |