Submission #493110

#TimeUsernameProblemLanguageResultExecution timeMemory
493110freddy645645Foehn Phenomena (JOI17_foehn_phenomena)C++17
100 / 100
120 ms5668 KiB
#include <bits/stdc++.h> #include <bits/extc++.h> //#define double long double #define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(nullptr); #define pb push_back #define UNIQUE(a) sort(ALL(a));a.resize(unique(ALL(a))-a.begin()); #define ALL(X) X.begin(),X.end() #define F(i,n) FF(i,0,(n)) #define F1(i,n) FF(i,1,(n)+1) #define FF(i,n,m) for(int i=(int)n;i<int(m);++i) #define rF(i,a,b) for(int i=a;i>=(int)b;--i) #define mkp(a,b) make_pair(a,b) #define Fi first #define Se second #define int ll //#pragma GCC optimize("O3")//,unroll-loops //#pragma GCC target("popcnt") using namespace std; template<typename T> bool remax(T& a, const T& b) {return b>a?a=b,1:0;} template<typename T> bool remin(T& a, const T& b) {return b<a?a=b,1:0;} template<typename T> void clear(T& a){ T b; swap(a,b); return; } using ll=long long; using ull=unsigned long long; using int128= __int128_t; using uint128= __uint128_t; using pii =pair<int,int> ; const double pi=acos(-1); const int N=2E5+5; const ll M=105; const ll INF_64=0x3f3f3f3f3f3f3f3f; const int INF_32=0x3f3f3f3f; const int16_t INF_16=0x3f3f; const int klog=20; const int mod=1000000007;//1000000007;//998244353 const double eps=1E-3; void gen(){ } int bit[N]; int lowbit(int x){ return x&-x; } void add(int x,int v){ for(int i=x;i<N;i+=lowbit(i)) bit[i]+=v; } int ask(int x){ int re=0; for(int i=x;i;i-=lowbit(i)) re+=bit[i]; return re; } void sol(){ int n,q,s,t;cin>>n>>q>>t>>s; int cur=0,pre=0; cin>>pre; F1(i,n){ int x;cin>>x; add(i,x-pre); cur+=(x-pre)*((x-pre>0)?t:s); pre=x; //cout<<ask(i)<<" \n"[i==n]; } //cerr<<cur<<"\n"; F(_,q){ int l,r,d;cin>>l>>r>>d; int tmp=ask(l)-ask(l-1); cur-=tmp*(tmp>0?t:s); cur+=(d+tmp)*((d+tmp)>0?t:s);//cout<<"||"<<(d+tmp)*((d+tmp)>0?t:s)<<"\n"; add(l,d); if(r!=n){ tmp=ask(r+1)-ask(r); cur-=tmp*(tmp>0?t:s); cur+=(tmp-d)*((tmp-d)>0?t:s); add(r+1,-d); } cout<<-cur<<"\n"; //F1(i,n) //cout<<ask(i)<<" \n"[i==n]; } } int32_t main(){ #ifdef LOCAL //freopen(".in","r",stdin); //freopen(".out","w",stdout); #endif // LOCAL IOS; int t=1; gen(); //cin>>t; FF(i,1,t+1){ //cout<<"Case #"<<i<<": "; sol(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...