제출 #670734

#제출 시각아이디문제언어결과실행 시간메모리
670734MohammadAghilFoehn Phenomena (JOI17_foehn_phenomena)C++17
100 / 100
139 ms7864 KiB
#include <bits/stdc++.h> // #pragma GCC optimize ("Ofast,unroll-loops") // #pragma GCC target ("avx2") using namespace std; typedef long long ll; typedef pair<int, int> pp; #define per(i,r,l) for(int i = (r); i >= (l); i--) #define rep(i,l,r) for(int i = (l); i < (r); i++) #define all(x) begin(x), end(x) #define sz(x) (int)(x).size() #define pb push_back #define ss second #define ff first void err(istringstream *iss){}template<typename T,typename ...Args> void err(istringstream *iss,const T &_val, const Args&...args){string _name;*iss>>_name;if(_name.back()==',')_name.pop_back();cerr<<_name<<" = "<<_val<<", ",err(iss,args...);} void IOS(){ cin.tie(0) -> sync_with_stdio(0); #ifndef ONLINE_JUDGE #define er(args ...) cerr << __LINE__ << ": ", err(new istringstream(string(#args)), args), cerr << endl #else #define er(args ...) 0 #endif } mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); const ll mod = 1e9 + 7, maxn = 2e5 + 5, lg = 22, inf = ll(1e9) + 5; ll pw(ll a,ll b,ll md=mod){if(!b)return 1;ll k=pw(a,b>>1ll,md);return k*k%md*(b&1ll?a:1)%md;} ll n, s, t; ll cr, fen[maxn], a[maxn]; void upd(int i, ll k){ for(i++; i < maxn; i += i&-i) fen[i] += k; } ll get(int i){ ll res = 0; for(i++; i; i -= i&-i) res += fen[i]; return res; } ll vl(int i){ if(i - n){ ll x = a[i] + get(i), y = a[i+1] + get(i+1); return (x - y)*(x < y? s: t); } return 0; } void upd(int l, int r, int k){ cr -= vl(l-1) + vl(r); upd(l, k), upd(r+1, -k); cr += vl(l-1) + vl(r); } int main(){ IOS(); int q; cin >> n >> q >> s >> t; rep(i,0,n+1) cin >> a[i]; rep(i,0,n) cr += vl(i); while(q--){ int l, r, k; cin >> l >> r >> k; upd(l, r, k); cout << cr << '\n'; } return 0-0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...