Submission #998346

#TimeUsernameProblemLanguageResultExecution timeMemory
998346mispertionFoehn Phenomena (JOI17_foehn_phenomena)C++14
100 / 100
87 ms7336 KiB
#include<bits/stdc++.h> using namespace std; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); typedef long long ll; #define int ll typedef unsigned long long ull; typedef long double ld; typedef pair<int, int> pii; typedef pair<ll, ll> pll; #define pb push_back #define all(x) x.begin(), x.end() #define sz(x) (int)x.size() #define mispertion ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0) #define F first #define S second #define getlast(s) (*s.rbegin()) #define debg cout << "OK\n" const ld PI = 3.1415926535; const int N = 2e5+10; const int M = 7e6 + 1; int mod = 998244353; const int infi = INT_MAX; const ll infl = LLONG_MAX; const int P = 2; int mult(int a, int b) { a %= mod; b %= mod; return a * 1LL * b % mod; } int sum(int a, int b) { a %= mod; b %= mod; if (a + b < 0) return a + b + mod; if (a + b >= mod) return a + b - mod; return a + b; } ll binpow(ll a, ll n, ll mod) { if (n == 0) return 1; if (n % 2 == 1) { return binpow(a, n - 1, mod) * a % mod; } else { ll b = binpow(a, n / 2, mod); return b * b % mod; } } int n, q, s, t, a[N], d[N], sm = 0; void solve(){ cin >> n >> q >> s >> t; for(int i = 0; i <= n; i++){ cin >> a[i]; if(i > 0) d[i] = a[i] - a[i - 1]; if(d[i] > 0) sm -= s * d[i]; else sm -= t * d[i]; } for(int j = 1; j <= q; j++){ int l, r, x; cin >> l >> r >> x; if(d[l] > 0) sm += s * d[l]; else sm += t * d[l]; d[l] += x; if(d[l] > 0) sm -= s * d[l]; else sm -= t * d[l]; if(r + 1 <= n){ if(d[r + 1] > 0) sm += s * d[r + 1]; else sm += t * d[r + 1]; d[r + 1] -= x; if(d[r + 1] > 0) sm -= s * d[r + 1]; else sm -= t * d[r + 1]; } cout << sm << '\n'; } } signed main() { mispertion; int t = 1; //cin >> t; while(t--){ solve(); } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...