# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1039972 | khanhtb | Foehn Phenomena (JOI17_foehn_phenomena) | C++14 | 88 ms | 13284 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.
#pragma GCC optimize("Ofast,unroll-loops")
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define ld long double
#define pb push_back
#define pf push_front
#define vi vector<ll>
#define vii vector<vi>
#define pll pair<ll, ll>
#define vpll vector<pll>
#define all(a) a.begin(), a.end()
#define fi first
#define se second
using namespace std;
const ll mod = 998244353;
const ll inf = 1e18;
const ll blocksz = 320;
const ll N = 2e5+8;
ll a[N],d[N],s,t;
int n,q;
ll ans = 0;
void update(int i, int x){
if(i > n) return;
if(d[i] > 0) ans -= d[i]*s*x;
else ans -= d[i]*t*x;
}
void solve(){
cin >> n >> q >> s >> t;
for(int i = 0; i <= n; i++) cin >> a[i];
for(int i = 1; i <= n; i++){
d[i] = a[i]-a[i-1];
update(i,1);
}
while(q--){
int l,r,x;cin >> l >> r >> x;
update(l,-1);
update(r+1,-1);
d[l] += x;
d[r+1] -= x;
update(l,1);
update(r+1,1);
cout << ans << '\n';
}
}
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
if (fopen("test.inp", "r")) {
freopen("test.inp", "r", stdin);
freopen("test.out", "w", stdout);
}
int T = 1;
// cin >> T;
for (int i = 1; i <= T; i++) {
solve();
cout << '\n';
}
}
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... |