# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
691901 | Paul_Liao_1457 | Foehn Phenomena (JOI17_foehn_phenomena) | C++17 | 129 ms | 13136 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//記得跳題
#include<iostream>
#include<array>
#include<vector>
#include<string>
#include<algorithm>
#include<set>
#include<queue>
#include<stack>
#include<math.h>
#include<map>
#include<unordered_map>
#include<cstring>
#include<iomanip>
#include<bitset>
#include<tuple>
#define ll long long
#define int ll
#define LL __int128_t
#define DB double
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define INF (ll)(2e9)
#define MOD (ll)(1e9+7)
#define F first
#define S second
#define endl "\n"
#define AC ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
/*
struct func
{
bool operator()(const int &a, const int &b) const
{
return a < b;
}
};
*/
using namespace std;
template<class T> using PQ=priority_queue<T,vector<T>,greater<T> >;
void file(){
freopen("/Users/liaoyunyang/Desktop/meta_in.txt","r",stdin);
freopen("/Users/liaoyunyang/Desktop/meta_out.txt","w",stdout);
}
ll dis[200005],a[200005];
signed main(){
AC;
ll n,q,s,t,c1=0,c2=0; cin>>n>>q>>s>>t;
FOR(i,0,n+1){
cin>>a[i];
if(i){
dis[i]=a[i]-a[i-1];
if(dis[i]>0) c1+=dis[i];
else c2+=dis[i];
}
}
//cout<<"c1="<<c1<<" c2="<<c2<<endl;
while(q--){
int l,r,x; cin>>l>>r>>x;
if(dis[l]>0&&dis[l]+x<=0){
c1-=dis[l]; c2+=dis[l]+x;
}
else if(dis[l]<=0&&dis[l]+x>0){
c2-=dis[l]; c1+=dis[l]+x;
}
else{
if(dis[l]>0) c1+=x;
else c2+=x;
}
if(r+1<=n){
if(dis[r+1]>0&&dis[r+1]-x<=0){
c1-=dis[r+1]; c2+=dis[r+1]-x;
}
else if(dis[r+1]<=0&&dis[r+1]-x>0){
c1+=dis[r+1]-x; c2-=dis[r+1];
}
else{
if(dis[r+1]>0) c1-=x;
else c2-=x;
}
}
dis[l]+=x; dis[r+1]-=x;
cout<<-(s*c1+t*c2)<<endl;
}
}
/*
4 5
1 2 4 4
1 3 2 1
4 3 1 2
4 1 6 1
2 4 2 5
*/
Compilation message (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... |