제출 #996927

#제출 시각아이디문제언어결과실행 시간메모리
996927ag_1204Foehn Phenomena (JOI17_foehn_phenomena)C++14
0 / 100
1090 ms157520 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long int int main(){ ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); ll n,q,s,t; cin>>n>>q>>s>>t; ll a[n+1],b[n]; ll wind=0; for (ll i=0;i<=n;i++) { cin>>a[i]; if (i>0) { b[i-1]=a[i]-a[i-1]; if (b[i-1]>0) { wind-=s*b[i-1]; } else { wind-=t*b[i-1]; } cout<<b[i-1]<<" "; } } cout<<endl; cout<<wind<<endl; while(q--) { ll l,r,x; cin>>l>>r>>x; if (x>0) { if (b[l-1]>0) { wind-=s*x; } else { if (b[l-1]+x<=0) { wind-=t*x; } else { wind+=t*b[l-1]; wind-=s*(x+b[l-1]); } } } else if (x<0) { if (b[l-1]+x>0) { wind-=s*x; } else { if (b[l-1]<=0) { wind-=t*x; } else { wind+=t*b[l-1]; wind-=s*(x+b[l-1]); } } } b[l-1]+=x; if (x<0) { if (b[r]>0) { wind-=s*x; } else { if (b[r]+x<=0) { wind-=t*x; } else { wind+=t*b[r]; wind-=s*(x+b[r]); } } } else if (x>0) { if (b[r]+x>0) { wind-=s*x; } else { if (b[r]<=0) { wind-=t*x; } else { wind+=t*b[r]; wind-=s*(x+b[r]); } } } b[r]-=x; for (auto y:b) { cout<<y<<" "; } cout<<endl; cout<<wind<<endl; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...