Submission #783722

#TimeUsernameProblemLanguageResultExecution timeMemory
783722kebineFoehn Phenomena (JOI17_foehn_phenomena)C++17
100 / 100
84 ms7256 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; #define fi first #define se second #define pb push_back #define TC int t; cin>>t; while(t--) #define all(x) (x).begin(),(x).end() //*AC BERSAMA ALLAH FORTIS FORTUNA ADIUVAT ll n,q,s,t; vector<ll> v, dif; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin>>n>>q>>s>>t; v.resize(n+5); dif.resize(n+5); ll sneg=0, spos=0, val=0; // stored in positive for(int i=0;i<=n;i++){ cin>>v[i]; if(i>0){ dif[i] = v[i]-v[i-1]; if(dif[i]<=0) sneg += (dif[i]*-1); else spos += dif[i]; } } // val = sneg * t - spos * s; // cout<<"::"<<spos<<"--"<<sneg<<'\n'; // cout<<"=="<<val<<'\n'; for(int i=1;i<=q;i++){ ll l,r,x; cin>>l>>r>>x; if(dif[l]<=0) sneg += dif[l]; else spos -= dif[l]; if(r==n); else if(dif[r+1]<=0) sneg += dif[r+1]; else spos -= dif[r+1]; // cout<<"::"<<spos<<"--"<<sneg<<'\n'; dif[l] += x; dif[r+1] -= x; if(dif[l]<=0) sneg -= dif[l]; else spos += dif[l]; if(r==n); else if(dif[r+1]<=0) sneg -= dif[r+1]; else spos += dif[r+1]; // cout<<"::"<<spos<<"--"<<sneg<<'\n'; val = sneg * t - spos * s; cout<<val<<'\n'; // cout<<val<<'\n'; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...