Submission #470476

#TimeUsernameProblemLanguageResultExecution timeMemory
470476Killer2501Foehn Phenomena (JOI17_foehn_phenomena)C++14
100 / 100
146 ms36632 KiB
#include <bits/stdc++.h> #define ll long long #define pll pair<ll, ll> #define pii pair<ll, pll> #define pb push_back #define fi first #define se second using namespace std; const int N = 5e5 + 5; const int M = 1300; const ll mod = 1e15 + 7; ll n, m, t, k, ans, b[N], dp[N], a[N], d[N], l[N], r[N], lab[N], s, pos, neg; vector<pll> adj[N]; vector<ll> kq, adt[N]; vector<pii> e; ll pw(ll k, ll n) { ll total = 1; for(; n; n >>= 1) { if(n & 1)total = total * k % mod; k = k * k % mod; } return total; } ll findp(ll u) { return lab[u] < 0 ? u : lab[u] = findp(lab[u]); } void hop(ll u, ll v) { if(lab[u] > lab[v])swap(u, v); lab[u] += lab[v]; lab[v] = u; } void add(ll x) { if(x > 0)pos += x; else neg -= x; } void del(ll x) { if(x > 0)pos -= x; else neg += x; } void sol() { cin >> n >> m >> s >> t; for(int i = 0; i <= n; i ++) { cin >> a[i]; b[i] = a[i] - a[i-1]; add(b[i]); } while(m -- > 0) { ll l, r, x; cin >> l >> r >> x; del(b[l]); b[l] += x; add(b[l]); if(r < n) { del(b[r+1]); b[r+1] -= x; add(b[r+1]); } cout << neg*t-pos*s<<'\n'; } } int main() { cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0); int test = 1; //cin >> test; while (test-- > 0) sol(); return 0; } /* 9 12 1 9 4 1 2 5 2 3 7 2 4 3 4 3 6 3 6 4 8 7 10 6 7 5 5 8 1 9 5 7 5 4 12 6 8 2 2 4 7 5 1 6 5 3 4 8 5 8 1 5 */ // ctrl + F8 = compile // ctrl + F9 = run
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...